Merge branch 'master' into jwi-bcc64xsingletonwarning
[ACE_TAO.git] / ACE / examples / Misc / test_profile_timer.cpp
blob042053f45d8f2f5f750f15b7d7e15c1ceb0de27f
1 #include "ace/OS_main.h"
2 #include "ace/Profile_Timer.h"
3 #include "ace/Log_Msg.h"
4 #include "ace/OS_NS_stdlib.h"
5 #include "ace/OS_NS_unistd.h"
8 static const int DEFAULT_ITERATIONS = 100000000;
10 int
11 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
13 ACE_Profile_Timer timer;
14 int iterations = argc > 1 ? ACE_OS::atoi (argv[1]) : DEFAULT_ITERATIONS;
16 timer.start ();
18 for (int i = 0; i < iterations; i++)
19 ACE_OS::getpid ();
21 timer.stop ();
23 ACE_Profile_Timer::ACE_Elapsed_Time et;
25 timer.elapsed_time (et);
27 ACE_DEBUG ((LM_DEBUG, "iterations = %d\n", iterations));
28 ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n",
29 et.real_time, et.user_time, et.system_time));
31 ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n",
32 (et.real_time / double (iterations)) * 1000000));
33 return 0;