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
#ifndef RCOUNTER_H
#define RCOUNTER_H

#include <sys/time.h>

class RegisterCounter
{
 public:
  typedef unsigned long long int   register_counter_t;
  RegisterCounter() { rtotal = 0; }<--- Member variable 'RegisterCounter::rbegin' is not initialized in the constructor.<--- Member variable 'RegisterCounter::rend' is not initialized in the constructor.

  void  reset() { rtotal  = 0; }
  void  start() { rbegin = rdtsc(); }

  void  stop()
    {
      rend  = rdtsc();
      rtotal +=  rend-rbegin;
    }
  register_counter_t  getCount() { return rtotal; }

 private:
  register_counter_t  rtotal, rbegin, rend;
  register_counter_t rdtsc()
    {
      register_counter_t x;
      __asm__ volatile(".byte 0x0f,0x31" : "=A" (x));
      return x;
    }
};

class StopWatch
{
 public:
  StopWatch(){ rtotal = 0; }<--- Member variable 'StopWatch::rbegin' is not initialized in the constructor.<--- Member variable 'StopWatch::rend' is not initialized in the constructor.

  void  reset(){ rtotal  = 0; }

  void  start() {
    gettimeofday(&tp, 0);
    rbegin = (double)tp.tv_sec + (1.E-06)*tp.tv_usec;
  }

  void  stop()
    {
      gettimeofday(&tp, 0);
      rend  = (double)tp.tv_sec + (1.E-06)*tp.tv_usec;
      rtotal +=  rend-rbegin;
    }

  double getSeconds() { return rtotal; }

 private:
  struct  timeval tp;
  double  rtotal, rbegin, rend;
};


#endif