source: golgotha/src/i4/time/sgi_prof.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 12 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 1.4 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9
10#include <time.h>
11
12class i4_profile_class
13{
14public:
15  static i4_profile_class *list;
16
17  i4_profile_class *next;
18  char *name;
19
20        timespec start_time;
21  double total_time;
22  w32 recursion_level;  // current level of recursion
23
24
25  i4_profile_class(char *debug_name) : name(debug_name)
26  {
27    recursion_level=0;
28    total_time=0;
29    next=list;
30    list=this;
31  }
32
33  void start()
34  {
35    if (recursion_level==0)
36                {
37                        clock_gettime(CLOCK_SGI_CYCLE, &start_time);
38                }
39
40    recursion_level++;
41 }
42
43  void stop()
44  {
45    recursion_level--;
46    if (recursion_level==0)
47    {
48      struct timespec end;
49                        clock_gettime(CLOCK_SGI_CYCLE, &end);
50
51      double endt=(double)(end.tv_sec+(double)end.tv_nsec/(double)10000000000000.0);
52      double startt=(double)(start_time.tv_sec+(double)start_time.tv_nsec/(double)10000000000000.0);
53
54      total_time+=endt-startt;
55    }
56  }
57} ;
Note: See TracBrowser for help on using the repository browser.