diff --git a/tests/benchmarks/corelib/serialization/qcborvalue/tst_bench_qcborvalue.cpp b/tests/benchmarks/corelib/serialization/qcborvalue/tst_bench_qcborvalue.cpp index 2c606ccafe..3400965176 100644 --- a/tests/benchmarks/corelib/serialization/qcborvalue/tst_bench_qcborvalue.cpp +++ b/tests/benchmarks/corelib/serialization/qcborvalue/tst_bench_qcborvalue.cpp @@ -39,10 +39,18 @@ private: template void doKeyLookup(); + template + void doConstruct(); + private slots: void keyLookupLatin1() { doKeyLookup(); } void keyLookupString() { doKeyLookup(); } void keyLookupConstCharPtr() { doKeyLookup(); }; + + void constructLatin1() { doConstruct(); } + void constructString() { doConstruct(); } + void constructStringView() { doConstruct(); } + void constructConstCharPtr() { doConstruct(); } }; template @@ -56,13 +64,28 @@ void tst_QCborValue::doKeyLookup() using Strings = SampleStrings; const Type s(Strings::key); QBENCHMARK { - const QCborValue r = v[s]; - Q_UNUSED(r); + [[maybe_unused]] const QCborValue r = v[s]; } } else { QBENCHMARK { - const QCborValue r = v[SampleStrings::key]; - Q_UNUSED(r); + [[maybe_unused]] const QCborValue r = v[SampleStrings::key]; + } + } +} + +template +void tst_QCborValue::doConstruct() +{ + if constexpr (hasValueType) { + using Char = std::remove_cv_t; + using Strings = SampleStrings; + const Type s(Strings::key); + QBENCHMARK { + [[maybe_unused]] const auto v = QCborValue{s}; + } + } else { + QBENCHMARK { + [[maybe_unused]] const auto v = QCborValue{SampleStrings::key}; } } }