MCPcopy Create free account
hub / github.com/KDE/kdevelop / benchPopFront

Function benchPopFront

kdevplatform/serialization/tests/bench_indexedstring.cpp:245–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243
244template<class Container>
245static void benchPopFront()
246{
247 const auto toElementType = [](int i) {
248 using ElementType = typename Container::value_type;
249 const auto str = QString::number(i);
250 if constexpr (std::is_integral_v<ElementType>) {
251 return IndexedString::indexForString(str);
252 } else {
253 return ElementType{str};
254 }
255 };
256
257 Container container;
258 for (int i = 0; i < 10000; ++i) {
259 container.push_back(toElementType(i));
260 }
261 // deliberately do a worst-case remove-from-front here
262 // we want to see how this performs without any noexcept move operators
263 QBENCHMARK_ONCE {
264 while (!container.empty()) {
265 container.erase(container.begin());
266 }
267 }
268}
269
270void BenchIndexedString::bench_string_vector()
271{

Callers

nothing calls this directly

Calls 3

emptyMethod · 0.80
push_backMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected