summaryrefslogtreecommitdiff
path: root/tests/tests.c
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2011-04-01 15:40:06 -0700
committerJoshua Haberman <joshua@reverberate.org>2011-04-01 15:40:06 -0700
commit9eb4d695c49a85f7f72ad68c3c31affd61fef984 (patch)
tree79b7fde57e6f31a19405688a5f9e29e3f9cf7ab2 /tests/tests.c
parent19517cc6f39871abf4a0705b49cfed9049ca6033 (diff)
First rough version of the JIT.
It can successfully parse SpeedMessage1. Preliminary results: 750MB/s on Core2 2.4GHz. This number is 2.5x proto2. This isn't apples-to-apples, because proto2 is parsing to a struct and we are just doing stream parsing, but for apps that are currently using proto2, this is the improvement they would see if they could move to stream-based processing. Unfortunately perf-regression-test.py is broken, and I'm not 100% sure why. It would be nice to fix it first (to ensure that there are no performance regressions for the table-based decoder) but I'm really impatient to get the JIT checked in.
Diffstat (limited to 'tests/tests.c')
-rw-r--r--tests/tests.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/tests/tests.c b/tests/tests.c
index a04b1da..2fe8b8d 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -5,8 +5,10 @@
#include "upb_def.h"
#include "upb_glue.h"
#include "upb_test.h"
+#include "upb_stream.h"
+#include "upb_decoder.h"
-static void test_upb_symtab() {
+static upb_symtab *load_test_proto() {
upb_symtab *s = upb_symtab_new();
ASSERT(s);
upb_string *descriptor = upb_strreadfile("tests/test.proto.pb");
@@ -16,10 +18,38 @@ static void test_upb_symtab() {
}
upb_status status = UPB_STATUS_INIT;
upb_parsedesc(s, descriptor, &status);
- upb_printerr(&status);
ASSERT(upb_ok(&status));
upb_status_uninit(&status);
upb_string_unref(descriptor);
+ return s;
+}
+
+static upb_flow_t upb_test_onvalue(void *closure, upb_value fval, upb_value val) {
+ (void)closure;
+ (void)fval;
+ (void)val;
+ return UPB_CONTINUE;
+}
+
+static void test_upb_jit() {
+ upb_symtab *s = load_test_proto();
+ upb_string *symname = upb_strdupc("SimplePrimitives");
+ upb_def *def = upb_symtab_lookup(s, symname);
+ upb_string_unref(symname);
+ ASSERT(def);
+
+ upb_handlers h;
+ upb_handlers_init(&h, upb_downcast_msgdef(def));
+ upb_register_all(&h, NULL, NULL, &upb_test_onvalue, NULL, NULL, NULL);
+ upb_decoder d;
+ upb_decoder_init(&d, &h);
+ upb_decoder_uninit(&d);
+ upb_symtab_unref(s);
+ upb_def_unref(def);
+}
+
+static void test_upb_symtab() {
+ upb_symtab *s = load_test_proto();
// Test cycle detection by making a cyclic def's main refcount go to zero
// and then be incremented to one again.
@@ -53,6 +83,7 @@ int main()
} while (0)
TEST(test_upb_symtab);
+ TEST(test_upb_jit);
printf("All tests passed (%d assertions).\n", num_assertions);
return 0;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback