-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathmain_bench.cpp
52 lines (38 loc) · 1.11 KB
/
main_bench.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
#include <iostream>
#include <type_traits>
#include <chrono>
#include "seephit.h"
using namespace std;
int main()
{
constexpr auto parser =
#include "test/loop_bench.spt"
REPORT_ERRORS(parser);
// Start timer and run it
auto tmStart = chrono::high_resolution_clock::now();
int k;
for(int i = 0; i < 1; ++i)
{
spt::tree spt_tree(parser);
spt::template_vals dct;
spt::template_funs dctFuns;
dctFuns["double"] =
[](ostream &ostr, const string &sKey, spt::template_vals &vals)
{
ostr << std::get<int>(vals[sKey]) * 2;
};
dctFuns["quote"] =
[](ostream &ostr, const string &sKey, spt::template_vals &vals)
{
ostr << '\'' << std::get<int>(vals[sKey]) << '\'';
};
spt_tree.root().render(cout, dct, dctFuns);
k = dct.size();
}
auto tmElapsed = chrono::high_resolution_clock::now() - tmStart;
long long nano = chrono::duration_cast<std::chrono::nanoseconds>(tmElapsed).count();
double ms = nano/1000000.0F;
cerr << ms << " ms elapsed" << endl;
cerr << k << " unique template keys" << endl;
cerr << endl;
}