summaryrefslogtreecommitdiff
path: root/tests/Timeprobe_Test.cpp
blob: 879ba85a06ed3cbab0b47ee102d297d1d74a5a6b (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// $Id$

// ============================================================================
//
// = LIBRARY
//    tests
//
// = FILENAME
//    Timeprobe_Test.cpp
//
// = DESCRIPTION
//      This is a simple test of Timeprobes.
//
// = AUTHOR
//    Irfan Pyarali
//
// ============================================================================

#if !defined (ACE_ENABLE_TIMEPROBES)
# define ACE_ENABLE_TIMEPROBES
#endif /* ! ACE_ENABLE_TIMEPROBES */

#if !defined (ACE_COMPILE_TIMEPROBES)
  // #include Timeprobe.cpp so that we get any necessary template
  // instantiations.
# define ACE_COMPILE_TIMEPROBES
# include "ace/Timeprobe.cpp"
#endif /* ! ACE_COMPILE_TIMEPROBES */

//#define ACE_MT_TIMEPROBES
//#define ACE_TSS_TIMEPROBES

#include "tests/test_config.h"
#include "ace/Timeprobe.h"

#if defined(__BORLANDC__) && __BORLANDC__ >= 0x0530
USELIB("..\ace\aced.lib");
//---------------------------------------------------------------------------
#endif /* defined(__BORLANDC__) && __BORLANDC__ >= 0x0530 */

static const char *events_descriptions_0[] =
{
  "Event Zero",
  "Event One",
  "Event Two",
  "Event Three",
  "Event Four",
  "Event Five",
  "Event Six",
  "Event Seven",
  "Event Eight",
  "Event Nine",
};

static const char *events_descriptions_1[] =
{
  "Work start",
  "Work end"
};

static void
work (int time)
{
  ACE_FUNCTION_TIMEPROBE (100);
  ACE_OS::sleep (time);
}

int
main (int, ASYS_TCHAR *[])
{
  ACE_START_TEST (ASYS_TEXT ("Timeprobe_Test"));

  ACE_TIMEPROBE ("Staring Test");

  for (int i = 1; i < 3; i++)
    {
      work (i);
      ACE_TIMEPROBE (i);
    }

  ACE_TIMEPROBE ("Ending Test");

  ACE_TIMEPROBE_EVENT_DESCRIPTIONS (events_descriptions_1, 100);
  ACE_TIMEPROBE_EVENT_DESCRIPTIONS (events_descriptions_0, 0);

  ACE_TIMEPROBE_PRINT;

  ACE_END_TEST;

  return 0;
}