summaryrefslogtreecommitdiff
path: root/benchmarks/parsetoproto2.upb.cc
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2014-12-09 16:01:56 -0800
committerJosh Haberman <jhaberman@gmail.com>2014-12-09 16:01:56 -0800
commit56913be6bb57f81dbbf7baf9cc9a0a2cd1a36493 (patch)
treef4d1c17aef4e5d01578ba3fd3926ca863e2792f2 /benchmarks/parsetoproto2.upb.cc
parent82be433d4188e0b3b992e463ad52ee148d3ad8de (diff)
Removed obsolete benchmarks/ and examples/ directories.
Diffstat (limited to 'benchmarks/parsetoproto2.upb.cc')
-rw-r--r--benchmarks/parsetoproto2.upb.cc57
1 files changed, 0 insertions, 57 deletions
diff --git a/benchmarks/parsetoproto2.upb.cc b/benchmarks/parsetoproto2.upb.cc
deleted file mode 100644
index 20b6381..0000000
--- a/benchmarks/parsetoproto2.upb.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-// Tests speed of upb parsing into proto2 generated classes.
-
-#define __STDC_LIMIT_MACROS 1
-#include "main.c"
-
-#include <stdint.h>
-#include "upb/bytestream.h"
-#include "upb/def.h"
-#include "upb/pb/decoder.h"
-#include "upb/pb/glue.h"
-#include "upb/bindings/google/bridge.h"
-#include MESSAGE_HFILE
-
-const char *str;
-size_t len;
-MESSAGE_CIDENT msg[NUM_MESSAGES];
-upb::SeededPipeline<8192> pipeline(upb_realloc, NULL);
-upb::Sink *decoder_sink;
-upb::Sink *proto2_sink;
-
-static bool initialize()
-{
- // Read the message data itself.
- str = upb_readfile(MESSAGE_FILE, &len);
- if(str == NULL) {
- fprintf(stderr, "Error reading " MESSAGE_FILE "\n");
- return false;
- }
-
- const upb::Handlers* h = upb::google::NewWriteHandlers(MESSAGE_CIDENT(), &h);
- const upb::Handlers* h2 = upb::pb::GetDecoderHandlers(h, JIT, &h2);
-
- proto2_sink = pipeline.NewSink(h);
- decoder_sink = pipeline.NewSink(h2);
- pipeline.DonateRef(h, &h);
- pipeline.DonateRef(h2, &h2);
-
- upb::pb::Decoder* d = decoder_sink->GetObject<upb::pb::Decoder>();
- upb::pb::ResetDecoderSink(d, proto2_sink);
-
- return true;
-}
-
-static void cleanup() {
-}
-
-static size_t run(int i) {
- pipeline.Reset();
- proto2_sink->Reset(&msg[i % NUM_MESSAGES]);
- msg[i % NUM_MESSAGES].Clear();
-
- if (!upb::PutStringToBytestream(decoder_sink, str, len)) {
- fprintf(stderr, "Decode error: %s", pipeline.status().GetString());
- return 0;
- }
- return len;
-}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback