From 3faba1ba729ab53264f5abb7381a1e806c19e082 Mon Sep 17 00:00:00 2001 From: sha512sum Date: Wed, 10 Apr 2024 16:47:55 +0000 Subject: [PATCH] Add initialise without sort benchmark --- benchmarks/init.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/benchmarks/init.cpp b/benchmarks/init.cpp index 48bf505..9d99c95 100644 --- a/benchmarks/init.cpp +++ b/benchmarks/init.cpp @@ -93,7 +93,31 @@ auto BMInitialise(benchmark::State& state) { state.ResumeTiming(); }; }; +auto BMInitialiseWithoutSort(benchmark::State& state) { + using Builder = decltype(cserver::ServiceContextBuilder{} + .AppendConfigParam<"threads", 8>() + .Append() + .Append() + .Append() + .Append() + .Append() + .Append() + .Append() + .Append()); + using ServiceContextType = decltype(Builder::GetServiceContext()); + alignas(ServiceContextType) std::byte context[sizeof(ServiceContextType)]; + for(auto _ : state) { + auto* ptr = new (context) ServiceContextType{}; + ptr->Run(); + ptr->FindComponent().ioContext.run(); + state.PauseTiming(); + ptr->~ServiceContextType(); + state.ResumeTiming(); + }; +}; + BENCHMARK(BMInitialise); +BENCHMARK(BMInitialiseWithoutSort); BENCHMARK_MAIN();