summaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2011-12-22 11:37:01 -0800
committerJoshua Haberman <jhaberman@gmail.com>2011-12-22 11:37:01 -0800
commit1bcab1377de6afe8c0f9c895cdba04baacf3e4a5 (patch)
tree4d478ccff5da0dee3c217c01f815ee1764965501 /benchmarks
parentb5f5ee867e6c91b77490dc8894236f17a47bde00 (diff)
Sync with internal Google development.
This breaks the open-source build, will follow up with a change to fix it.
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/parsestream.upb.c3
-rw-r--r--benchmarks/parsetoproto2.upb.cc24
-rw-r--r--benchmarks/parsetostruct.upb.c8
3 files changed, 14 insertions, 21 deletions
diff --git a/benchmarks/parsestream.upb.c b/benchmarks/parsestream.upb.c
index 19d8ccf..4d13e9d 100644
--- a/benchmarks/parsestream.upb.c
+++ b/benchmarks/parsestream.upb.c
@@ -76,7 +76,8 @@ static size_t run(int i)
(void)i;
upb_status status = UPB_STATUS_INIT;
upb_stringsrc_reset(&stringsrc, input_str, input_len);
- upb_decoder_reset(&decoder, upb_stringsrc_allbytes(&stringsrc), NULL);
+ upb_decoder_reset(&decoder, upb_stringsrc_bytesrc(&stringsrc),
+ 0, UPB_NONDELIMITED, NULL);
upb_decoder_decode(&decoder, &status);
if(!upb_ok(&status)) goto err;
return input_len;
diff --git a/benchmarks/parsetoproto2.upb.cc b/benchmarks/parsetoproto2.upb.cc
index 03a1039..75cd10c 100644
--- a/benchmarks/parsetoproto2.upb.cc
+++ b/benchmarks/parsetoproto2.upb.cc
@@ -24,7 +24,6 @@
#include <google/protobuf/descriptor.h>
#undef private
-char *str;
static size_t len;
MESSAGE_CIDENT msg[NUM_MESSAGES];
MESSAGE_CIDENT msg2;
@@ -54,13 +53,9 @@ upb_flow_t proto2_setstr(void *m, upb_value fval, upb_value val) {
const upb_fielddef *f = upb_value_getfielddef(fval);
std::string **str = (std::string**)UPB_INDEX(m, f->offset, 1);
if (*str == f->default_ptr) *str = new std::string;
- const upb_byteregion *ref = upb_value_getbyteregion(val);
- uint32_t len;
- (*str)->assign(
- upb_byteregion_getptr(ref, upb_byteregion_startofs(ref), &len),
- upb_byteregion_len(ref));
- assert(len == upb_byteregion_len(ref));
+ const upb_strref *ref = upb_value_getstrref(val);
// XXX: only supports contiguous strings atm.
+ (*str)->assign(ref->ptr, ref->len);
return UPB_CONTINUE;
}
@@ -69,13 +64,9 @@ upb_flow_t proto2_append_str(void *_r, upb_value fval, upb_value val) {
typedef google::protobuf::RepeatedPtrField<std::string> R;
(void)fval;
R *r = (R*)_r;
- const upb_byteregion *ref = upb_value_getbyteregion(val);
+ const upb_strref *ref = upb_value_getstrref(val);
// XXX: only supports contiguous strings atm.
- uint32_t len;
- r->Add()->assign(
- upb_byteregion_getptr(ref, upb_byteregion_startofs(ref), &len),
- upb_byteregion_len(ref));
- assert(len == upb_byteregion_len(ref));
+ r->Add()->assign(ref->ptr, ref->len);
return UPB_CONTINUE;
}
@@ -274,7 +265,7 @@ static bool initialize()
upb_symtab_unref(s);
// Read the message data itself.
- str = upb_readfile(MESSAGE_FILE, &len);
+ char *str = upb_readfile(MESSAGE_FILE, &len);
if(str == NULL) {
fprintf(stderr, "Error reading " MESSAGE_FILE "\n");
return false;
@@ -284,6 +275,7 @@ static bool initialize()
msg2.ParseFromArray(str, len);
upb_stringsrc_init(&strsrc);
+ upb_stringsrc_reset(&strsrc, str, len);
upb_handlers *h = upb_handlers_new();
upb_accessors_reghandlers(h, def);
if (!JIT) h->should_jit = false;
@@ -304,8 +296,8 @@ static size_t run(int i)
(void)i;
upb_status status = UPB_STATUS_INIT;
msg[i % NUM_MESSAGES].Clear();
- upb_stringsrc_reset(&strsrc, str, len);
- upb_decoder_reset(&d, upb_stringsrc_allbytes(&strsrc), &msg[i % NUM_MESSAGES]);
+ upb_decoder_reset(&d, upb_stringsrc_bytesrc(&strsrc),
+ 0, UPB_NONDELIMITED, &msg[i % NUM_MESSAGES]);
upb_decoder_decode(&d, &status);
if(!upb_ok(&status)) goto err;
return len;
diff --git a/benchmarks/parsetostruct.upb.c b/benchmarks/parsetostruct.upb.c
index 4eeafbb..5e7aa35 100644
--- a/benchmarks/parsetostruct.upb.c
+++ b/benchmarks/parsetostruct.upb.c
@@ -8,7 +8,6 @@
#include "upb/pb/glue.h"
static const upb_msgdef *def;
-char *str;
static size_t len;
static void *msg[NUM_MESSAGES];
static upb_stringsrc strsrc;
@@ -34,7 +33,7 @@ static bool initialize()
upb_symtab_unref(s);
// Read the message data itself.
- str = upb_readfile(MESSAGE_FILE, &len);
+ char *str = upb_readfile(MESSAGE_FILE, &len);
if(str == NULL) {
fprintf(stderr, "Error reading " MESSAGE_FILE "\n");
return false;
@@ -44,6 +43,7 @@ static bool initialize()
msg[i] = upb_stdmsg_new(def);
upb_stringsrc_init(&strsrc);
+ upb_stringsrc_reset(&strsrc, str, len);
upb_handlers *h = upb_handlers_new();
upb_accessors_reghandlers(h, def);
if (!JIT) h->should_jit = false;
@@ -70,8 +70,8 @@ static size_t run(int i)
upb_status status = UPB_STATUS_INIT;
i %= NUM_MESSAGES;
upb_msg_clear(msg[i], def);
- upb_stringsrc_reset(&strsrc, str, len);
- upb_decoder_reset(&d, upb_stringsrc_allbytes(&strsrc), msg[i]);
+ upb_decoder_reset(&d, upb_stringsrc_bytesrc(&strsrc),
+ 0, UPB_NONDELIMITED, msg[i]);
upb_decoder_decode(&d, &status);
if(!upb_ok(&status)) goto err;
return len;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback