simple test if we need explicit suffixes

 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
std::default_random_engine generator;
std::uniform_int_distribution<long> distribution(0, container.size_in_symbols());
auto dice = std::bind(distribution, generator);
std::vector<long> tester = std::vector<long>(5*container.size_in_symbols());
std::vector<Unislice> slices = std::vector<Unislice>(5*container.size_in_symbols());
long long *measures = new long long[5*container.size_in_symbols()];
for (long i = 0, len = 5*container.size_in_symbols(); i < len; i++)
tester[i] = dice();
long long max = 0;
std::cout << "Measuring suffix found perfomance on direct suffix storage:" << std::endl;
for (long i = 0, len = tester.size(); i < len; i++) {
auto begin = std::chrono::high_resolution_clock::now();
slices[i] = container.suffix(tester[i]);
auto end = std::chrono::high_resolution_clock::now();
measures[i] = std::chrono::duration_cast<std::chrono::nanoseconds>(end-begin).count();
if (measures[i] > max) max = measures[i];
}
std::cout << "average: " << array_average(measures, tester.size()) << " ns." << std::endl;
std::cout << "max: " << max << " ns." << std::endl;
max = 0;
std::cout << std::endl;
std::cout << "Measuring suffix found perfomance on binsearch suffixes:" << std::endl;
for (long i = 0, len = tester.size(); i < len; i++) {
auto begin = std::chrono::high_resolution_clock::now();
slices[i] = container.suffix_with_binsearch(tester[i]);
auto end = std::chrono::high_resolution_clock::now();
measures[i] = std::chrono::duration_cast<std::chrono::nanoseconds>(end-begin).count();
if (measures[i] > max) max = measures[i];
}
std::cout << "average: " << array_average(measures, tester.size()) << " ns." << std::endl;
std::cout << "max: " << max << " ns." << std::endl;
max = 0;
std::cout << std::endl;
std::cout << "Measuring suffix found perfomance on stl_lower_bound suffixes:" << std::endl;
for (long i = 0, len = tester.size(); i < len; i++) {
auto begin = std::chrono::high_resolution_clock::now();
slices[i] = container.suffix_with_stl(tester[i]);
auto end = std::chrono::high_resolution_clock::now();
measures[i] = std::chrono::duration_cast<std::chrono::nanoseconds>(end-begin).count();
if (measures[i] > max) max = measures[i];
}
std::cout << "average: " << array_average(measures, tester.size()) << " ns." << std::endl;
std::cout << "max: " << max << " ns." << std::endl;
std::cout << std::endl;