-
Notifications
You must be signed in to change notification settings - Fork 6
/
bench-all.cc
47 lines (43 loc) · 1.03 KB
/
bench-all.cc
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
#include <iostream>
#include <sys/time.h>
extern "C" int str_cc_main(int ac, char** av);
extern "C" int cc_main(int ac, char** av);
extern "C" int str_rs_main();
extern "C" int rs_main();
auto run = [](char const* name, auto f) {
timeval before, after;
gettimeofday(&before, nullptr);
for (int t = 0; t < 200; ++t)
f();
gettimeofday(&after, nullptr);
long long t = (after.tv_sec - before.tv_sec) * 1000000 +
(after.tv_usec - before.tv_usec);
std::cerr << t / 1000000.0 << ' ' << name << '\n';
};
int main(int ac, char** av)
{
#ifdef STRCC
run("str-cc", [ac,av]() { str_cc_main(ac, av); });
#endif
#ifdef CC
run("cc", [ac,av]() { cc_main(ac, av); });
#endif
#ifdef STRRS
run("str-rs", str_rs_main);
#endif
#ifdef RS
run("rs", rs_main);
#endif
#ifdef RS
run("rs", rs_main);
#endif
#ifdef STRRS
run("str-rs", str_rs_main);
#endif
#ifdef CC
run("cc", [ac,av]() { cc_main(ac, av); });
#endif
#ifdef STRCC
run("str-cc", [ac,av]() { str_cc_main(ac, av); });
#endif
}