diff options
-rw-r--r-- | benchmarks/parsetostruct.upb_table.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/benchmarks/parsetostruct.upb_table.c b/benchmarks/parsetostruct.upb_table.c index 406229b..592f86e 100644 --- a/benchmarks/parsetostruct.upb_table.c +++ b/benchmarks/parsetostruct.upb_table.c @@ -58,11 +58,23 @@ static bool initialize() upb_decoder_init(&d, def); upb_msgpopulator_init(&p); upb_handlers_init(&h); + + if (!BYREF) { + // Pretend the input string is stack-allocated, which will force its data + // to be copied instead of referenced. There is no good reason to do this, + // except to benchmark against proto2 more fairly, which in its open-source + // release does not support referencing the input string. + input_str->refcount.v = _UPB_STRING_REFCOUNT_STACK; + } return true; } static void cleanup() { + if (!BYREF) { + // Undo our fabrication from before. + input_str->refcount.v = 1; + } upb_string_unref(input_str); upb_msg_unref(msg, def); upb_def_unref(UPB_UPCAST(def)); |