diff --git a/benchmarks/parsetostruct.upb_table.c b/benchmarks/parsetostruct.upb_table.c index dfdad3657d..406229b782 100644 --- a/benchmarks/parsetostruct.upb_table.c +++ b/benchmarks/parsetostruct.upb_table.c @@ -10,6 +10,10 @@ static upb_string *input_str; static upb_msgdef *def; static upb_msg *msg; +static upb_stringsrc strsrc; +static upb_decoder d; +static upb_handlers h; +static upb_msgpopulator p; static bool initialize() { @@ -49,6 +53,11 @@ static bool initialize() } upb_status_uninit(&status); msg = upb_msg_new(def); + + upb_stringsrc_init(&strsrc); + upb_decoder_init(&d, def); + upb_msgpopulator_init(&p); + upb_handlers_init(&h); return true; } @@ -57,6 +66,10 @@ static void cleanup() upb_string_unref(input_str); upb_msg_unref(msg, def); upb_def_unref(UPB_UPCAST(def)); + upb_stringsrc_uninit(&strsrc); + upb_decoder_uninit(&d); + upb_msgpopulator_uninit(&p); + upb_handlers_uninit(&h); } static size_t run(int i) @@ -64,7 +77,15 @@ static size_t run(int i) (void)i; upb_status status = UPB_STATUS_INIT; upb_msg_clear(msg, def); - upb_strtomsg(input_str, msg, def, &status); + upb_stringsrc_reset(&strsrc, input_str); + upb_decoder_reset(&d, upb_stringsrc_bytesrc(&strsrc)); + upb_msgpopulator_reset(&p, msg, def); + upb_handlers_init(&h); + upb_msgpopulator_register_handlers(&p, &h); + upb_src *src = upb_decoder_src(&d); + upb_src_sethandlers(src, &h); + + upb_src_run(src, &status); if(!upb_ok(&status)) goto err; upb_status_uninit(&status); return upb_string_len(input_str);