summaryrefslogtreecommitdiff
path: root/benchmarks/parsetostruct.upb.c
diff options
context:
space:
mode:
Diffstat (limited to 'benchmarks/parsetostruct.upb.c')
-rw-r--r--benchmarks/parsetostruct.upb.c14
1 files changed, 8 insertions, 6 deletions
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;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback