summaryrefslogtreecommitdiff
path: root/core/perftools.hpp
blob: 91cf56e9bd27346e213d68b9e2612c8c10ceb3bb (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
#ifndef U6JSwQqqOviv7kQT0JaHQQr1VDI
#define U6JSwQqqOviv7kQT0JaHQQr1VDI

#include <sys/time.h>
#include <stdio.h>

////// THROUGHPUT

void print_throughput(double time, double num, char * title) {
  fprintf(stderr, "%s: %lfs\t%lf/s\n", title, time, num / time);
}

void print_throughput2(double time, double num, long base) {
  fprintf(stderr, "%ld:\t%lfs\t%lf/s\n", base, time, num / time);
}

////// TIMER

class Timer {
public:
  Timer();

  double diff();

  timeval start;
};

Timer::Timer() {
  gettimeofday(&start,NULL);
}

double Timer::diff() {
  timeval stop;

  gettimeofday(&stop,NULL);

  return (stop.tv_sec + stop.tv_usec/1000000.0) - (start.tv_sec + start.tv_usec/1000000.0);
}

#endif // U6JSwQqqOviv7kQT0JaHQQr1VDI
contact: Jan Huwald // Impressum