summaryrefslogtreecommitdiff
path: root/benchmark.c
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-07-07 16:59:08 -0700
committerJoshua Haberman <joshua@reverberate.org>2009-07-07 16:59:08 -0700
commit127adf4036baa5d6c41d59b4e2b3462b4180c2d6 (patch)
treec4ddfa465ccdbcf695ca3e9804ecf2c8f75eaa86 /benchmark.c
parent137991c7b2def357b9f18d0cd01ba671ebf1392d (diff)
More work on the benchmark.
Diffstat (limited to 'benchmark.c')
-rw-r--r--benchmark.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/benchmark.c b/benchmark.c
index 03d8456..aede9d3 100644
--- a/benchmark.c
+++ b/benchmark.c
@@ -1,4 +1,5 @@
+#include "test_util.h"
#include "upb_context.h"
#include "upb_msg.h"
@@ -7,7 +8,7 @@ int main ()
struct upb_context c;
upb_context_init(&c);
struct upb_string fds;
- if(!upb_strreadfile("google_speed.proto.bin", &fds)) {
+ if(!upb_strreadfile("google_messages.proto.bin", &fds)) {
fprintf(stderr, "Couldn't read google_speed.proto.bin.\n");
return 1;
}
@@ -34,16 +35,19 @@ int main ()
fprintf(stderr, "Error reading google_message2.dat\n");
return 1;
}
- upb_status_t status = upb_msg_parse(&s, str.ptr, str.byte_len, &read);
+ size_t total = 0;
+ for(int i = 0; i < 1000; 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=%d\n", status, read);
+ return 1;
+ }
+ total += str.byte_len;
+ }
+ fprintf(stderr, "Parsed %sB\n", eng(total, 3, false));
upb_msg_parse_free(&s);
upb_msgdata_free(data, m, true);
upb_context_free(&c);
upb_strfree(str);
- if(status == UPB_STATUS_OK && read == str.byte_len) {
- fprintf(stderr, "Success!\n");
- return 0;
- } else {
- fprintf(stderr, "Error. :( error=%d, read=%d\n", status, read);
- return 1;
- }
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback