File: test_profile_timer.cpp

package info (click to toggle)
ace 8.0.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 46,932 kB
  • sloc: cpp: 341,621; perl: 31,868; sh: 1,963; python: 529; yacc: 511; xml: 330; lex: 158; lisp: 116; makefile: 85; csh: 20; ansic: 19; tcl: 5
file content (35 lines) | stat: -rw-r--r-- 859 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "ace/OS_main.h"
#include "ace/Profile_Timer.h"
#include "ace/Log_Msg.h"
#include "ace/OS_NS_stdlib.h"
#include "ace/OS_NS_unistd.h"


static const int DEFAULT_ITERATIONS = 100000000;

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  ACE_Profile_Timer timer;
  int iterations = argc > 1 ? ACE_OS::atoi (argv[1]) : DEFAULT_ITERATIONS;

  timer.start ();

  for (int i = 0; i < iterations; i++)
    ACE_OS::getpid ();

  timer.stop ();

  ACE_Profile_Timer::ACE_Elapsed_Time et;

  timer.elapsed_time (et);

  ACE_DEBUG ((LM_DEBUG, "iterations = %d\n", iterations));
  ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n",
              et.real_time, et.user_time, et.system_time));

  ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n",
              (et.real_time / double (iterations)) * 1000000));
  return 0;
}