From c0d2a75e235ce22c2835dd2485e5e15f3602c3cb Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 11 Aug 2023 22:30:08 +0100 Subject: Add perf test over DB SQL select complex --- slicer/db/Jamfile.jam | 35 +++++++++++++++++++++++++++++++++++ slicer/db/testPerf.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 slicer/db/testPerf.cpp diff --git a/slicer/db/Jamfile.jam b/slicer/db/Jamfile.jam index 73c05e5..a304b9e 100644 --- a/slicer/db/Jamfile.jam +++ b/slicer/db/Jamfile.jam @@ -4,6 +4,7 @@ import ../test/slicer.jam ; lib dbppcore : : : : /usr/include/dbpp ; lib dbpp-postgresql : : : : /usr/include/dbpp-postgresql ; lib stdc++fs ; +lib benchmark ; obj sqlExceptions : sqlExceptions.ice : ../slicer//slicer tidy:none ; lib slicer-db : @@ -137,6 +138,40 @@ run testUpdate.cpp testUpdate ; +run + [ obj perf : testPerf.cpp : + pure + ../test//types + ../test//types + benchmark + stdc++fs + dbpp-postgresql + dbppcore + ..//adhocutil + ../test//common + ../slicer//slicer + ../slicer//slicer + testCommon + testCommon + slicer-db + ] + : : : + benchmark + stdc++fs + dbpp-postgresql + dbppcore + ../test//common + ../test//types + ../slicer//slicer + ../slicer//slicer + slicer-db + ..//adhocutil + testCommon + testCommon + profile:on + off + : testPerf ; + alias install : install-lib install-slice ; explicit install ; explicit install-lib ; diff --git a/slicer/db/testPerf.cpp b/slicer/db/testPerf.cpp new file mode 100644 index 0000000..2f98cd2 --- /dev/null +++ b/slicer/db/testPerf.cpp @@ -0,0 +1,24 @@ +#include "sqlSelectDeserializer.h" +#include "testMockCommon.h" +#include +#include +#include +#include +#include + +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( + 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())); + } +} + +BENCHMARK_MAIN(); -- cgit v1.2.3