From bdb28b5a45aa81416e3b8e239e18bd668b2b95d2 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 14 Feb 2011 22:06:36 -0800 Subject: Make "byval" benchmarks actually byval. --- benchmarks/parsetostruct.upb_table.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'benchmarks/parsetostruct.upb_table.c') 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)); -- cgit v1.2.3