From a13873276bad57fec0655c0bf27a3ada4ade5192 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Fri, 10 Jul 2009 20:13:15 -0700 Subject: Performance improvements. --- benchmark/benchmark.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'benchmark') diff --git a/benchmark/benchmark.cc b/benchmark/benchmark.cc index efdac24..10713a8 100644 --- a/benchmark/benchmark.cc +++ b/benchmark/benchmark.cc @@ -43,7 +43,7 @@ int main () size_t total = 0; clock_t before = clock(); for(int i = 0; i < 2000; i++) { - upb_msg_parse_reset(&s, data, m, false, true); + upb_msg_parse_reset(&s, data, m, false, false); upb_status_t status = upb_msg_parse(&s, str.ptr, str.byte_len, &read); if(status != UPB_STATUS_OK && read != str.byte_len) { fprintf(stderr, "Error. :( error=%d, read=%lu\n", status, read); @@ -54,6 +54,21 @@ int main () double elapsed = ((double)clock() - before) / CLOCKS_PER_SEC; fprintf(stderr, "upb parsed %sB, ", eng(total, 3, false)); fprintf(stderr, "%sB/s\n", eng(total/elapsed, 3, false)); + + total = 0; + before = clock(); + for(int i = 0; i < 2000; i++) { + upb_msg_parse_reset(&s, data, m, false, true); + upb_status_t status = upb_msg_parse(&s, str.ptr, str.byte_len, &read); + if(status != UPB_STATUS_OK && read != str.byte_len) { + fprintf(stderr, "Error. :( error=%d, read=%lu\n", status, read); + return 1; + } + total += str.byte_len; + } + elapsed = ((double)clock() - before) / CLOCKS_PER_SEC; + fprintf(stderr, "upb(byref) parsed %sB, ", eng(total, 3, false)); + fprintf(stderr, "%sB/s\n", eng(total/elapsed, 3, false)); upb_msg_parse_free(&s); upb_msgdata_free(data, m, true); upb_context_free(&c); -- cgit v1.2.3