summaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2010-01-05 18:30:36 -0800
committerJoshua Haberman <joshua@reverberate.org>2010-01-05 18:30:36 -0800
commit5864888c6e7424af70d84802b55879f406d2d7b2 (patch)
tree3608dbcc1ef7f34542835221743c8fcbe9e3b128 /benchmarks
parentd75197375876538332d6d81aa4e8edd13b8f26c1 (diff)
parent6a8dfa5f26500b90aa9ecab418abba98d1e4e356 (diff)
Merge branch 'data-refactoring'. Ported benchmarks.
Conflicts: src/upb_data.c src/upb_data.h
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/parsetostruct.upb_table.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/benchmarks/parsetostruct.upb_table.c b/benchmarks/parsetostruct.upb_table.c
index 045aedb..e387de6 100644
--- a/benchmarks/parsetostruct.upb_table.c
+++ b/benchmarks/parsetostruct.upb_table.c
@@ -1,14 +1,13 @@
#include "main.c"
+#include "upb_data.h"
#include "upb_def.h"
-#include "upb_mm.h"
-#include "upb_msg.h"
static struct upb_symtab *s;
-static struct upb_string *str;
+static upb_strptr str;
static struct upb_msgdef *def;
-static struct upb_msg *msgs[NUM_MESSAGES];
+static upb_msg *msgs[NUM_MESSAGES];
static struct upb_msgparser *mp;
static bool initialize()
@@ -16,8 +15,8 @@ static bool initialize()
// Initialize upb state, parse descriptor.
struct upb_status status = UPB_STATUS_INIT;
s = upb_symtab_new();
- struct upb_string *fds = upb_strreadfile(MESSAGE_DESCRIPTOR_FILE);
- if(!fds) {
+ upb_strptr fds = upb_strreadfile(MESSAGE_DESCRIPTOR_FILE);
+ if(upb_string_isnull(fds)) {
fprintf(stderr, "Couldn't read " MESSAGE_DESCRIPTOR_FILE ": %s.\n",
status.msg);
return false;
@@ -30,7 +29,7 @@ static bool initialize()
}
upb_string_unref(fds);
- struct upb_string *proto_name = upb_strdupc(MESSAGE_NAME);
+ upb_strptr proto_name = upb_strdupc(MESSAGE_NAME);
def = upb_downcast_msgdef(upb_symtab_lookup(s, proto_name));
if(!def) {
fprintf(stderr, "Error finding symbol '" UPB_STRFMT "'.\n",
@@ -44,7 +43,7 @@ static bool initialize()
// Read the message data itself.
str = upb_strreadfile(MESSAGE_FILE);
- if(!str) {
+ if(upb_string_isnull(str)) {
fprintf(stderr, "Error reading " MESSAGE_FILE "\n");
return false;
}
@@ -55,7 +54,7 @@ static bool initialize()
static void cleanup()
{
for(int i = 0; i < NUM_MESSAGES; i++)
- upb_msg_unref(msgs[i]);
+ upb_msg_unref(msgs[i], def);
upb_string_unref(str);
upb_symtab_unref(s);
upb_msgparser_free(mp);
@@ -64,13 +63,13 @@ static void cleanup()
static size_t run(int i)
{
struct upb_status status = UPB_STATUS_INIT;
- struct upb_msg *msg = msgs[i%NUM_MESSAGES];
- upb_msgparser_reset(mp, msg, false);
- upb_msg_clear(msg);
- upb_msgparser_parse(mp, str->ptr, str->byte_len, &status);
+ upb_msg *msg = msgs[i%NUM_MESSAGES];
+ upb_msgparser_reset(mp, msg);
+ upb_msg_clear(msg, def);
+ upb_msgparser_parse(mp, str, &status);
if(!upb_ok(&status)) {
fprintf(stderr, "Parse error: %s\n", status.msg);
return 0;
}
- return str->byte_len;
+ return upb_strlen(str);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback