Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#362) Added stumpless_param_to_string benchmark #392

Merged
merged 2 commits into from
Dec 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions test/performance/param.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ NEW_MEMORY_COUNTER( load_param )
NEW_MEMORY_COUNTER( new_param )
NEW_MEMORY_COUNTER( set_param_name )
NEW_MEMORY_COUNTER( from_string )
NEW_MEMORY_COUNTER( param_to_string )

static void FromString(benchmark::State& state) {
const char *param = "test-param-name=\"test-param-value\"";
Expand Down Expand Up @@ -130,8 +131,30 @@ static void SetParamName(benchmark::State& state){
SET_STATE_COUNTERS( state, set_param_name );
}

static void ParamToString(benchmark::State& state){
struct stumpless_param *param;
const char *result;

INIT_MEMORY_COUNTER( param_to_string );

param = stumpless_new_param( "new-param-name", "new-param-value" );

for(auto _ : state){
result = stumpless_param_to_string( param );
goatshriek marked this conversation as resolved.
Show resolved Hide resolved
if( !result ) {
state.SkipWithError( "could not convert the param to string" );
}
}

stumpless_destroy_param( param );
stumpless_free_all( );

SET_STATE_COUNTERS( state, param_to_string );
}

BENCHMARK(CopyParam);
BENCHMARK(LoadParam);
BENCHMARK(NewParam);
BENCHMARK(SetParamName);
BENCHMARK(FromString);
BENCHMARK(ParamToString);