From 7c71f2c3750f5650f1c39f834702da137e874cf6 Mon Sep 17 00:00:00 2001 From: Kirubakaran Date: Tue, 17 Oct 2023 08:04:35 +0530 Subject: [PATCH] Added benchmark for stumpless_param_from_string --- test/performance/param.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/performance/param.cpp b/test/performance/param.cpp index b5b56f3f6..2e942a95a 100644 --- a/test/performance/param.cpp +++ b/test/performance/param.cpp @@ -24,6 +24,25 @@ NEW_MEMORY_COUNTER( copy_param ) NEW_MEMORY_COUNTER( load_param ) NEW_MEMORY_COUNTER( new_param ) NEW_MEMORY_COUNTER( set_param_name ) +NEW_MEMORY_COUNTER( from_string ) + +static void FromString(benchmark::State& state) { + const char *param = "test-param-name=\"test-param-value\""; + struct stumpless_param *result; + + INIT_MEMORY_COUNTER( from_string ); + + for (auto _ : state) { + result = stumpless_new_param_from_string(param); + if (!result) { + state.SkipWithError("could not create a new param from string"); + } + + stumpless_destroy_param(result); + } + + SET_STATE_COUNTERS(state, from_string); +} static void CopyParam(benchmark::State& state){ struct stumpless_param *param; @@ -115,3 +134,4 @@ BENCHMARK(CopyParam); BENCHMARK(LoadParam); BENCHMARK(NewParam); BENCHMARK(SetParamName); +BENCHMARK(FromString);