-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbench.c
44 lines (33 loc) · 757 Bytes
/
bench.c
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
#include <stdio.h>
#include "bench.h"
#include "cpucycles.h"
// Private Definitions
//Stores the time measured before the execution of the benchmark.
static long long before;
//Stores the time measured after the execution of the benchmark.
static long long after;
//Stores the sum of timings for the current benchmark.
static long long total;
// Public Definitions
void bench_reset() {
total = 0;
}
void bench_before() {
before = cpucycles();
}
void bench_after() {
long long result;
after = cpucycles();
result = (after - before);
total += result;
}
void bench_compute(int benches) {
total = total / benches;
}
void bench_print() {
printf("%lld cycles\n", total);
printf("\n");
}
unsigned long long bench_get_total() {
return total;
}