MCPcopy Create free account
hub / github.com/ada-url/ada / SpecialQuery

Function SpecialQuery

benchmarks/percent_encode.cpp:114–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112BENCHMARK(Query);
113
114static void SpecialQuery(benchmark::State& state) {
115 for (auto _ : state) {
116 for (std::string& url_string : examples) {
117 benchmark::DoNotOptimize(ada::unicode::percent_encode(
118 url_string, ada::character_sets::FRAGMENT_PERCENT_ENCODE));
119 }
120 }
121 if (collector.has_events()) {
122 counters::event_aggregate aggregate{};
123 for (size_t i = 0; i < N; i++) {
124 std::atomic_thread_fence(std::memory_order_acquire);
125 collector.start();
126 for (std::string& url_string : examples) {
127 benchmark::DoNotOptimize(ada::unicode::percent_encode(
128 url_string, ada::character_sets::SPECIAL_QUERY_PERCENT_ENCODE));
129 }
130 std::atomic_thread_fence(std::memory_order_release);
131 counters::event_count allocate_count = collector.end();
132 aggregate << allocate_count;
133 }
134 state.counters["instructions/url"] =
135 aggregate.best.instructions() / std::size(examples);
136 state.counters["instructions/cycle"] =
137 aggregate.total.instructions() / aggregate.total.cycles();
138 state.counters["instructions/byte"] =
139 aggregate.best.instructions() / examples_bytes;
140 state.counters["GHz"] =
141 aggregate.total.cycles() / aggregate.total.elapsed_ns();
142 }
143 state.counters["time/byte"] = benchmark::Counter(
144 examples_bytes, benchmark::Counter::kIsIterationInvariantRate |
145 benchmark::Counter::kInvert);
146 state.counters["time/url"] =
147 benchmark::Counter(double(std::size(examples)),
148 benchmark::Counter::kIsIterationInvariantRate |
149 benchmark::Counter::kInvert);
150 state.counters["speed"] = benchmark::Counter(
151 examples_bytes, benchmark::Counter::kIsIterationInvariantRate);
152 state.counters["url/s"] =
153 benchmark::Counter(double(std::size(examples)),
154 benchmark::Counter::kIsIterationInvariantRate);
155}
156BENCHMARK(SpecialQuery);
157
158static void UserInfo(benchmark::State& state) {

Callers

nothing calls this directly

Calls 2

percent_encodeFunction · 0.85
endMethod · 0.80

Tested by

no test coverage detected