From 59d7c024f6f8b52201ed585a0be165736fc10049 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 20 Jul 2009 03:32:20 -0700 Subject: Updates to benchmark. --- benchmark/benchmark.cc | 30 +++++++++++++++--------------- benchmark/google_messages.proto | 2 ++ 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'benchmark') diff --git a/benchmark/benchmark.cc b/benchmark/benchmark.cc index 95709bc..10713a8 100644 --- a/benchmark/benchmark.cc +++ b/benchmark/benchmark.cc @@ -73,19 +73,19 @@ int main () upb_msgdata_free(data, m, true); upb_context_free(&c); - //benchmarks::SpeedMessage2 msg; - //std::string stlstr(str.ptr, str.byte_len); - //upb_strfree(str); - //total = 0; - //before = clock(); - //for(int i = 0; i < 2000; i++) { - // if(!msg.ParseFromString(stlstr)) { - // fprintf(stderr, "Error parsing with proto2.\n"); - // return 1; - // } - // total += str.byte_len; - //} - //elapsed = ((double)clock() - before) / CLOCKS_PER_SEC; - //fprintf(stderr, "proto2 parsed %sB, ", eng(total, 3, false)); - //fprintf(stderr, "%sB/s\n", eng(total/elapsed, 3, false)); + benchmarks::SpeedMessage2 msg; + std::string stlstr(str.ptr, str.byte_len); + upb_strfree(str); + total = 0; + before = clock(); + for(int i = 0; i < 2000; i++) { + if(!msg.ParseFromString(stlstr)) { + fprintf(stderr, "Error parsing with proto2.\n"); + return 1; + } + total += str.byte_len; + } + elapsed = ((double)clock() - before) / CLOCKS_PER_SEC; + fprintf(stderr, "proto2 parsed %sB, ", eng(total, 3, false)); + fprintf(stderr, "%sB/s\n", eng(total/elapsed, 3, false)); } diff --git a/benchmark/google_messages.proto b/benchmark/google_messages.proto index 97356ec..17cace7 100644 --- a/benchmark/google_messages.proto +++ b/benchmark/google_messages.proto @@ -1,6 +1,8 @@ package benchmarks; +option optimize_for = SPEED; + message SpeedMessage1 { required string field1 = 1; optional string field9 = 9; -- cgit v1.2.3