Here is an article http://groups.google.com/groups?selm=2l2ucgF7jv50U1%40uni-berlin.de from http://groups.google.com/groups?group=microsoft.public.vc.language
"Victor Bazarov" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is it a known issue that in VC++ RTL the function 'clock()' > reports the wall clock instead of CPU time used? I ran this > test program on Windows and Unix: > ----------------------------------------- > #include <iostream> > #include <ctime> > > using namespace std; > > int main() > { > time_t t0 = time(0); > clock_t c0 = clock(); > > for (int i = 0; i < 10; ++i) > { > cout << "push > " << flush; > char a; > cin >> a; > cout << endl; > } > > cout << "Difference in wall clock is " > << difftime(time(0), t0) << endl; > cout << "Difference in CPU ticks is " > << double(clock() - c0) / CLOCKS_PER_SEC << endl; > > return 0; > } > ------------------------------------------- > and got very similar values on Windows and quite different > values on Unix. It seems that on Windows it just takes the > time() at the beginning and then 'clock' simply takes the > difference between current time and the stored value and > multiplies it with CLOCKS_PER_SEC... > > I know of GetProcessTimes() function, but couldn't 'clock()' > be implemented to use it? > > Thanks. > > Victor Windows 2000. The problem is not only with VC++ RTL. The program has been compiled: * with Microsoft C++ 13.00.9466 for 80x86 cl /EHsc program.cpp -o a_ms.exe * with gcc version 3.3.1 (cygming special) g++ -mno-cygwin -o a_mgw program.cpp // Use the Mingw32 interface g++ -o a_cyg program.cpp // Cygwin Here are results: $ a_ms [---omitted---] Difference in wall clock is 11 Difference in CPU ticks is 11.847 $ a_mgw [---omitted---] Difference in wall clock is 10 Difference in CPU ticks is 10.925 $ a_cyg [---omitted---] Difference in wall clock is 9 Difference in CPU ticks is 0.03 Here are DLLs: a_ms.exe C:\WINNT\system32\KERNEL32.dll C:\WINNT\system32\NTDLL.DLL a_mgw.exe C:\WINNT\system32\msvcrt.dll C:\WINNT\system32\KERNEL32.dll C:\WINNT\system32\NTDLL.DLL a_cyg.exe C:\cygwin\bin\cygwin1.dll C:\WINNT\system32\ADVAPI32.DLL C:\WINNT\system32\NTDLL.DLL C:\WINNT\system32\KERNEL32.DLL C:\WINNT\system32\RPCRT4.DLL It seems that the problem is in DLLs (?). -- Alex Vinokur http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/