From 06b8181f975d66341fe8b96999c911a8ed24447c Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Fri, 19 Aug 2011 17:19:53 -0700 Subject: Benchmark to parse into proto2 messages. --- benchmarks/parsetostruct.upb.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'benchmarks/parsetostruct.upb.c') diff --git a/benchmarks/parsetostruct.upb.c b/benchmarks/parsetostruct.upb.c index a436fd4..64a4d35 100644 --- a/benchmarks/parsetostruct.upb.c +++ b/benchmarks/parsetostruct.upb.c @@ -9,7 +9,7 @@ static upb_msgdef *def; static size_t len; -static void *msg; +static void *msg[NUM_MESSAGES]; static upb_stringsrc strsrc; static upb_decoder d; @@ -38,7 +38,8 @@ static bool initialize() return false; } upb_status_uninit(&status); - msg = upb_stdmsg_new(def); + for (int i = 0; i < NUM_MESSAGES; i++) + msg[i] = upb_stdmsg_new(def); upb_stringsrc_init(&strsrc); upb_stringsrc_reset(&strsrc, str, len); @@ -56,7 +57,8 @@ static bool initialize() static void cleanup() { - upb_stdmsg_free(msg, def); + for (int i = 0; i < NUM_MESSAGES; i++) + upb_stdmsg_free(msg[i], def); upb_def_unref(UPB_UPCAST(def)); upb_stringsrc_uninit(&strsrc); upb_decoder_uninit(&d); @@ -64,10 +66,10 @@ static void cleanup() static size_t run(int i) { - (void)i; upb_status status = UPB_STATUS_INIT; - upb_msg_clear(msg, def); - upb_decoder_reset(&d, upb_stringsrc_bytesrc(&strsrc), 0, UINT64_MAX, msg); + i %= NUM_MESSAGES; + upb_msg_clear(msg[i], def); + upb_decoder_reset(&d, upb_stringsrc_bytesrc(&strsrc), 0, UINT64_MAX, msg[i]); upb_decoder_decode(&d, &status); if(!upb_ok(&status)) goto err; return len; -- cgit v1.2.3