-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbenchCTermpose.cpp
51 lines (38 loc) · 1.3 KB
/
benchCTermpose.cpp
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
#include <stdlib.h>
#include <stdio.h>
#include <chrono>
#include <numeric>
#include <string.h>
#include "termpose.h"
#include "termpose.c"
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
char const* readFile(char const* name){
int fd = open(name, O_RDONLY);
int len = lseek(fd, 0, SEEK_END);
void *data = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0);
return (char const*)data;
}
int main(int argc, char** argv){
char const* dat = readFile("longterm.term");
TermposeParsingError err;
unsigned n = 4000;
unsigned total = 0;
auto begin = std::chrono::high_resolution_clock::now();
// logfile << s << "," << << std::endl;
// struct timespec startTime, endTime;
// clock_gettime(CLOCK_REALTIME, &startTime); //there's no CLOCK_REALTIME nor clock_gettime on my system? In time.h? It just isn't there?
for(unsigned i=0; i<n; ++i){
Term_t* result = parse(dat, &err);
total += *(unsigned*)(void*)&result;
}
auto end = std::chrono::high_resolution_clock::now();
// clock_gettime(CLOCK_REALTIME, &endTime);
// struct timespec dif = diff(startTime, endTime);
// <<":"<<<<endl;
double perTest = (double)std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin).count()/n;
printf("the result was %u, the time taken was %f per test\n", total, perTest);
return 0;
}