From 9128c51c7315375515a104b1bea2cfe8ca966881 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 21 Aug 2023 21:38:03 +0100 Subject: Add a DB perf case for a complex with non-optional members --- slicer/db/testPerf.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/slicer/db/testPerf.cpp b/slicer/db/testPerf.cpp index 2f98cd2..bb2a4c3 100644 --- a/slicer/db/testPerf.cpp +++ b/slicer/db/testPerf.cpp @@ -1,6 +1,7 @@ #include "sqlSelectDeserializer.h" #include "testMockCommon.h" #include +#include #include #include #include @@ -8,17 +9,29 @@ const StandardMockDatabase db; -class CoreFixture : public benchmark::Fixture, public ConnectionFixture { }; - -BENCHMARK_F(CoreFixture, bulk_select_complex)(benchmark::State & state) -{ - auto sel = db->select(R"SQL( +class CoreFixture : public benchmark::Fixture, public ConnectionFixture { +protected: + template + void + do_bulk_select_complex(benchmark::State & state) + { + auto sel = db->select(R"SQL( SELECT s mint, CAST(s AS NUMERIC(7,1)) mdouble, CAST(s as text) mstring, s % 2 = 0 mbool FROM GENERATE_SERIES(1, 10000) s)SQL"); - for (auto _ : state) { - benchmark::DoNotOptimize( - Slicer::DeserializeAny(sel.get())); + for (auto _ : state) { + benchmark::DoNotOptimize(Slicer::DeserializeAny(sel.get())); + } } +}; + +BENCHMARK_F(CoreFixture, bulk_select_complex)(benchmark::State & state) +{ + do_bulk_select_complex(state); +} + +BENCHMARK_F(CoreFixture, bulk_select_complex_non_optional)(benchmark::State & state) +{ + do_bulk_select_complex(state); } BENCHMARK_MAIN(); -- cgit v1.2.3