From 306bc554c67c23ddd52e5ece0e3971214b2da4e7 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 4 Aug 2009 22:06:02 -0700 Subject: More work on benchmarks (performance tests). --- benchmarks/parsetostruct.proto2_table.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'benchmarks/parsetostruct.proto2_table.cc') diff --git a/benchmarks/parsetostruct.proto2_table.cc b/benchmarks/parsetostruct.proto2_table.cc index 815834e..ded267d 100644 --- a/benchmarks/parsetostruct.proto2_table.cc +++ b/benchmarks/parsetostruct.proto2_table.cc @@ -8,7 +8,7 @@ static std::string str; static google::protobuf::DynamicMessageFactory factory; -static google::protobuf::Message *msg; +static google::protobuf::Message *msg[NUM_MESSAGES]; static bool initialize() { @@ -25,18 +25,20 @@ static bool initialize() /* Create the DynamicMessage. */ const google::protobuf::Message *dynamic_msg_prototype = factory.GetPrototype(MESSAGE_CIDENT::descriptor()); - msg = dynamic_msg_prototype->New(); + for(int i = 0; i < NUM_MESSAGES; i++) + msg[i] = dynamic_msg_prototype->New(); return true; } static void cleanup() { - delete msg; + for(int i = 0; i < NUM_MESSAGES; i++) + delete msg[i]; } -static size_t run() +static size_t run(int i) { - if(!msg->ParseFromString(str)) { + if(!msg[i%NUM_MESSAGES]->ParseFromString(str)) { fprintf(stderr, "Error parsing with proto2.\n"); return 0; } -- cgit v1.2.3