| 68 | BENCHMARK(Fragment); |
| 69 | |
| 70 | static void Query(benchmark::State& state) { |
| 71 | for (auto _ : state) { |
| 72 | for (std::string& url_string : examples) { |
| 73 | benchmark::DoNotOptimize(ada::unicode::percent_encode( |
| 74 | url_string, ada::character_sets::QUERY_PERCENT_ENCODE)); |
| 75 | } |
| 76 | } |
| 77 | if (collector.has_events()) { |
| 78 | counters::event_aggregate aggregate{}; |
| 79 | for (size_t i = 0; i < N; i++) { |
| 80 | std::atomic_thread_fence(std::memory_order_acquire); |
| 81 | collector.start(); |
| 82 | for (std::string& url_string : examples) { |
| 83 | benchmark::DoNotOptimize(ada::unicode::percent_encode( |
| 84 | url_string, ada::character_sets::QUERY_PERCENT_ENCODE)); |
| 85 | } |
| 86 | std::atomic_thread_fence(std::memory_order_release); |
| 87 | counters::event_count allocate_count = collector.end(); |
| 88 | aggregate << allocate_count; |
| 89 | } |
| 90 | state.counters["instructions/url"] = |
| 91 | aggregate.best.instructions() / std::size(examples); |
| 92 | state.counters["instructions/cycle"] = |
| 93 | aggregate.total.instructions() / aggregate.total.cycles(); |
| 94 | state.counters["instructions/byte"] = |
| 95 | aggregate.best.instructions() / examples_bytes; |
| 96 | state.counters["GHz"] = |
| 97 | aggregate.total.cycles() / aggregate.total.elapsed_ns(); |
| 98 | } |
| 99 | state.counters["time/byte"] = benchmark::Counter( |
| 100 | examples_bytes, benchmark::Counter::kIsIterationInvariantRate | |
| 101 | benchmark::Counter::kInvert); |
| 102 | state.counters["time/url"] = |
| 103 | benchmark::Counter(double(std::size(examples)), |
| 104 | benchmark::Counter::kIsIterationInvariantRate | |
| 105 | benchmark::Counter::kInvert); |
| 106 | state.counters["speed"] = benchmark::Counter( |
| 107 | examples_bytes, benchmark::Counter::kIsIterationInvariantRate); |
| 108 | state.counters["url/s"] = |
| 109 | benchmark::Counter(double(std::size(examples)), |
| 110 | benchmark::Counter::kIsIterationInvariantRate); |
| 111 | } |
| 112 | BENCHMARK(Query); |
| 113 | |
| 114 | static void SpecialQuery(benchmark::State& state) { |
nothing calls this directly
no test coverage detected