summaryrefslogtreecommitdiff
path: root/benchmarks
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
parent82be433d4188e0b3b992e463ad52ee148d3ad8de (diff)
Removed obsolete benchmarks/ and examples/ directories.
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/getgraphs.py35
-rw-r--r--benchmarks/google_message1.datbin228 -> 0 bytes
-rw-r--r--benchmarks/google_message2.datbin84570 -> 0 bytes
-rw-r--r--benchmarks/google_messages.proto149
-rw-r--r--benchmarks/main.c55
-rw-r--r--benchmarks/parsestream.upb.c94
-rw-r--r--benchmarks/parsetoproto2.upb.cc57
-rw-r--r--benchmarks/parsetostruct.proto2_compiled.cc37
-rw-r--r--benchmarks/parsetostruct.proto2_table.cc46
9 files changed, 0 insertions, 473 deletions
diff --git a/benchmarks/getgraphs.py b/benchmarks/getgraphs.py
deleted file mode 100644
index aacf6b2..0000000
--- a/benchmarks/getgraphs.py
+++ /dev/null
@@ -1,35 +0,0 @@
-
-import sys
-
-benchmarks = {}
-color_map = {'proto2_compiled': 'FF0000',
- 'proto2_table': 'FF00FF',
- 'upb_table_byref': '0000FF',
- 'upb_table_byval': '00FF00'}
-for line in sys.stdin:
- name, val = line.split(': ')
- components = name.split('_')
- benchmark = '_'.join(components[1:3])
- variant = '_'.join(components[3:])
- if benchmark not in benchmarks:
- benchmarks[benchmark] = []
- benchmarks[benchmark].append((variant, int(val)))
-
-def encode(x):
- digits = (range(ord("A"), ord("Z")+1) + range(ord("a"), ord("z")+1) +
- range(ord("0"), ord("9")+1) + [ord("."), ord("-")])
- return chr(digits[x / 64]) + chr(digits[x % 64])
-
-for benchmark, values in benchmarks.items():
- def cmp(a, b):
- return b[1] - a[1]
- values.sort(cmp)
- variants = [x[0] for x in values]
- values = [x[1] for x in values]
- scaling = 400
- encoded_values = [encode((x * 4096 / scaling) - 1) for x in values]
- legend = "chdl=%s" % ("|".join(variants))
- colors = "chco=%s" % ("|".join([color_map[x] for x in variants]))
- data = "chd=e:%s" % ("".join(encoded_values))
- url = "http://chart.apis.google.com/chart?cht=bhs&chs=500x200&chtt=%s+(MB/s)&chxt=x&chxr=0,0,%d&%s" % (benchmark, scaling, "&".join([legend, data, colors]))
- print url
diff --git a/benchmarks/google_message1.dat b/benchmarks/google_message1.dat
deleted file mode 100644
index bc0f064..0000000
--- a/benchmarks/google_message1.dat
+++ /dev/null
Binary files differ
diff --git a/benchmarks/google_message2.dat b/benchmarks/google_message2.dat
deleted file mode 100644
index 06c0944..0000000
--- a/benchmarks/google_message2.dat
+++ /dev/null
Binary files differ
diff --git a/benchmarks/google_messages.proto b/benchmarks/google_messages.proto
deleted file mode 100644
index 489c470..0000000
--- a/benchmarks/google_messages.proto
+++ /dev/null
@@ -1,149 +0,0 @@
-
-package benchmarks;
-
-option optimize_for = SPEED;
-
-enum Foo {
- FOO_VALUE = 1;
- FOO_VALUE2 = 2;
-}
-
-message Simple {
- message M2 {
- optional int32 f1 = 1234567;
- }
- optional M2 m2 = 1;
-}
-
-message SpeedMessage1 {
- required string field1 = 1;
- optional string field9 = 9;
- optional string field18 = 18;
- optional bool field80 = 80 [default=false];
- optional bool field81 = 81 [default=true];
- required int32 field2 = 2;
- required int32 field3 = 3;
- optional int32 field280 = 280;
- optional int32 field6 = 6 [default=0];
- optional int64 field22 = 22;
- optional string field4 = 4;
- repeated fixed64 field5 = 5;
- optional bool field59 = 59 [default=false];
- optional string field7 = 7;
- optional int32 field16 = 16;
- optional int32 field130 = 130 [default=0];
- optional bool field12 = 12 [default=true];
- optional bool field17 = 17 [default=true];
- optional bool field13 = 13 [default=true];
- optional bool field14 = 14 [default=true];
- optional int32 field104 = 104 [default=0];
- optional int32 field100 = 100 [default=0];
- optional int32 field101 = 101 [default=0];
- optional string field102 = 102;
- optional string field103 = 103;
- optional int32 field29 = 29 [default=0];
- optional bool field30 = 30 [default=false];
- optional int32 field60 = 60 [default=-1];
- optional int32 field271 = 271 [default=-1];
- optional int32 field272 = 272 [default=-1];
- optional int32 field150 = 150;
- optional int32 field23 = 23 [default=0];
- optional bool field24 = 24 [default=false];
- optional int32 field25 = 25 [default=0];
- optional SpeedMessage1SubMessage field15 = 15;
- optional bool field78 = 78;
- optional int32 field67 = 67 [default=0];
- optional int32 field68 = 68;
- optional int32 field128 = 128 [default=0];
- optional string field129 = 129 [default="xxxxxxxxxxxxxxxxxxxxx"];
- optional int32 field131 = 131 [default=0];
- optional Foo field132 = 132 [default=FOO_VALUE];
-}
-
-message SpeedMessage1SubMessage {
- optional int32 field1 = 1 [default=0];
- optional int32 field2 = 2 [default=0];
- optional int32 field3 = 3 [default=0];
- optional string field15 = 15 [default="FOOBAR!"];
- optional bool field12 = 12 [default=true];
- optional int64 field13 = 13;
- optional int64 field14 = 14;
- optional int32 field16 = 16;
- optional int32 field19 = 19 [default=2];
- optional bool field20 = 20 [default=true];
- optional bool field28 = 28 [default=true];
- optional fixed64 field21 = 21;
- optional int32 field22 = 22;
- optional bool field23 = 23 [ default=false ];
- optional bool field206 = 206 [default=false];
- optional fixed32 field203 = 203;
- optional int32 field204 = 204;
- optional string field205 = 205;
- optional uint64 field207 = 207;
- optional uint64 field300 = 300;
-}
-
-message SpeedMessage2 {
- optional string field1 = 1;
- optional int64 field3 = 3;
- optional int64 field4 = 4;
- optional int64 field30 = 30;
- optional bool field75 = 75 [default=false];
- optional string field6 = 6;
- optional bytes field2 = 2;
- optional int32 field21 = 21 [default=0];
- optional int32 field71 = 71;
- optional float field25 = 25;
- optional int32 field109 = 109 [default=0];
- optional int32 field210 = 210 [default=0];
- optional int32 field211 = 211 [default=0];
- optional int32 field212 = 212 [default=0];
- optional int32 field213 = 213 [default=0];
- optional int32 field216 = 216 [default=0];
- optional int32 field217 = 217 [default=0];
- optional int32 field218 = 218 [default=0];
- optional int32 field220 = 220 [default=0];
- optional int32 field221 = 221 [default=0];
- optional float field222 = 222 [default=0.0];
- optional int32 field63 = 63;
-
- repeated group Group1 = 10 {
- required float field11 = 11;
- optional float field26 = 26;
- optional string field12 = 12;
- optional string field13 = 13;
- repeated string field14 = 14;
- required uint64 field15 = 15;
- optional int32 field5 = 5;
- optional string field27 = 27;
- optional int32 field28 = 28;
- optional string field29 = 29;
- optional string field16 = 16;
- repeated string field22 = 22;
- repeated int32 field73 = 73;
- optional int32 field20 = 20 [default=0];
- optional string field24 = 24;
- optional SpeedMessage2GroupedMessage field31 = 31;
- }
- repeated string field128 = 128;
- optional int64 field131 = 131;
- repeated string field127 = 127;
- optional int32 field129 = 129;
- repeated int64 field130 = 130;
- optional bool field205 = 205 [default=false];
- optional bool field206 = 206 [default=false];
-}
-
-message SpeedMessage2GroupedMessage {
- optional float field1 = 1;
- optional float field2 = 2;
- optional float field3 = 3 [default=0.0];
- optional bool field4 = 4;
- optional bool field5 = 5;
- optional bool field6 = 6 [default=true];
- optional bool field7 = 7 [default=false];
- optional float field8 = 8;
- optional bool field9 = 9;
- optional float field10 = 10;
- optional int64 field11 = 11;
-}
diff --git a/benchmarks/main.c b/benchmarks/main.c
deleted file mode 100644
index 3d98a05..0000000
--- a/benchmarks/main.c
+++ /dev/null
@@ -1,55 +0,0 @@
-
-#include <stdbool.h>
-#include <time.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-
-/* Cycle between a bunch of different messages, to avoid performance
- * variations due to memory effects of a particular allocation pattern. */
-#ifndef NUM_MESSAGES
-#define NUM_MESSAGES 32
-#endif
-
-static bool initialize();
-static void cleanup();
-static size_t run(int i);
-
-int main (int argc, char *argv[])
-{
- (void)argc;
-
- /* Change cwd to where the binary is. */
- char *lastslash = strrchr(argv[0], '/');
- char *progname = argv[0];
- if(lastslash) {
- *lastslash = '\0';
- if(chdir(argv[0]) < 0) {
- fprintf(stderr, "Error changing directory to %s.\n", argv[0]);
- return 1;
- }
- *lastslash = '/';
- progname = lastslash + 3; /* "/b_" */
- }
-
- if(!initialize()) {
- fprintf(stderr, "%s: failed to initialize\n", argv[0]);
- return 1;
- }
-
- size_t total_bytes = 0;
- clock_t before = clock();
- for(int i = 0; true; i++) {
- if((i & 0xFF) == 0 && (clock() - before > CLOCKS_PER_SEC)) break;
- size_t bytes = run(i);
- if(bytes == 0) {
- fprintf(stderr, "%s: failed.\n", argv[0]);
- return 2;
- }
- total_bytes += bytes;
- }
- double elapsed = ((double)clock() - before) / CLOCKS_PER_SEC;
- printf("%s:%d\n", progname, (int)(total_bytes / elapsed / (1 << 20)));
- cleanup();
- return 0;
-}
diff --git a/benchmarks/parsestream.upb.c b/benchmarks/parsestream.upb.c
deleted file mode 100644
index 2c5f943..0000000
--- a/benchmarks/parsestream.upb.c
+++ /dev/null
@@ -1,94 +0,0 @@
-
-#include "main.c"
-
-#include <stdlib.h>
-#include "upb/bytestream.h"
-#include "upb/def.h"
-#include "upb/pb/decoder.h"
-#include "upb/pb/glue.h"
-
-static char *input_str;
-static size_t input_len;
-static const upb_msgdef *def;
-upb_pipeline pipeline;
-static upb_sink *sink;
-
-static void *startsubmsg(void *closure, const void *hd) {
- UPB_UNUSED(closure);
- UPB_UNUSED(hd);
- return input_str;
-}
-
-void onmreg(void *c, upb_handlers *h) {
- UPB_UNUSED(c);
- upb_msg_iter i;
- upb_msg_begin(&i, upb_handlers_msgdef(h));
- for(; !upb_msg_done(&i); upb_msg_next(&i)) {
- const upb_fielddef *f = upb_msg_iter_field(&i);
- if (upb_fielddef_type(f) == UPB_TYPE_MESSAGE) {
- upb_handlers_setstartsubmsg(h, f, startsubmsg, NULL, NULL);
- }
- }
-}
-
-static bool initialize()
-{
- // Initialize upb state, decode descriptor.
- upb_status status = UPB_STATUS_INIT;
- upb_symtab *s = upb_symtab_new(&s);
- upb_load_descriptor_file_into_symtab(s, MESSAGE_DESCRIPTOR_FILE, &status);
- if(!upb_ok(&status)) {
- fprintf(stderr, "Error reading descriptor: %s\n",
- upb_status_getstr(&status));
- return false;
- }
-
- def = upb_dyncast_msgdef(upb_symtab_lookup(s, MESSAGE_NAME, &def));
- if(!def) {
- fprintf(stderr, "Error finding symbol '%s'.\n", MESSAGE_NAME);
- return false;
- }
- upb_symtab_unref(s, &s);
-
- // Read the message data itself.
- input_str = upb_readfile(MESSAGE_FILE, &input_len);
- if(input_str == NULL) {
- fprintf(stderr, "Error reading " MESSAGE_FILE "\n");
- return false;
- }
-
- // Cause all messages to be read, but do nothing when they are.
- const upb_handlers* handlers =
- upb_handlers_newfrozen(def, NULL, &handlers, &onmreg, NULL);
- const upb_handlers* decoder_handlers =
- upb_pbdecoder_gethandlers(handlers, JIT, &decoder_handlers);
- upb_msgdef_unref(def, &def);
-
- upb_pipeline_init(&pipeline, NULL, 0, upb_realloc, NULL);
- upb_sink *s2 = upb_pipeline_newsink(&pipeline, handlers);
- sink = upb_pipeline_newsink(&pipeline, decoder_handlers);
- upb_pipeline_donateref(&pipeline, decoder_handlers, &decoder_handlers);
- upb_pipeline_donateref(&pipeline, handlers, &handlers);
- upb_pbdecoder *decoder = upb_sink_getobj(sink);
- upb_pbdecoder_resetsink(decoder, s2);
- return true;
-}
-
-static void cleanup()
-{
- free(input_str);
- upb_pipeline_uninit(&pipeline);
-}
-
-static size_t run(int i)
-{
- (void)i;
- upb_pipeline_reset(&pipeline);
- if (!upb_bytestream_putstr(sink, input_str, input_len)) {
- fprintf(stderr, "Decode error: %s",
- upb_status_getstr(upb_pipeline_status(&pipeline)));
- return 0;
- }
- return input_len;
-
-}
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;
-}
diff --git a/benchmarks/parsetostruct.proto2_compiled.cc b/benchmarks/parsetostruct.proto2_compiled.cc
deleted file mode 100644
index 5b7c18e..0000000
--- a/benchmarks/parsetostruct.proto2_compiled.cc
+++ /dev/null
@@ -1,37 +0,0 @@
-
-#include "main.c"
-#include MESSAGE_HFILE
-#include <string>
-#include <iostream>
-#include <sstream>
-#include <fstream>
-
-static std::string str;
-MESSAGE_CIDENT msg[NUM_MESSAGES];
-
-static bool initialize()
-{
- // Read the message data itself. */
- std::ifstream stream(MESSAGE_FILE);
- if(!stream.is_open()) {
- fprintf(stderr, "Error opening " MESSAGE_FILE ".\n");
- return false;
- }
- std::stringstream stringstream;
- stringstream << stream.rdbuf();
- str = stringstream.str();
- return true;
-}
-
-static void cleanup()
-{
-}
-
-static size_t run(int i)
-{
- if(!msg[i%NUM_MESSAGES].ParsePartialFromString(str)) {
- fprintf(stderr, "Error parsing with proto2.\n");
- return 0;
- }
- return str.size();
-}
diff --git a/benchmarks/parsetostruct.proto2_table.cc b/benchmarks/parsetostruct.proto2_table.cc
deleted file mode 100644
index 83546ae..0000000
--- a/benchmarks/parsetostruct.proto2_table.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-
-#include "main.c"
-#include <google/protobuf/dynamic_message.h>
-#include <iostream>
-#include <sstream>
-#include <fstream>
-#include MESSAGE_HFILE
-
-static std::string str;
-static google::protobuf::DynamicMessageFactory factory;
-static google::protobuf::Message *msg[NUM_MESSAGES];
-
-static bool initialize()
-{
- // Read the message data itself.
- std::ifstream stream(MESSAGE_FILE);
- if(!stream.is_open()) {
- fprintf(stderr, "Error opening " MESSAGE_FILE ".\n");
- return false;
- }
- std::stringstream stringstream;
- stringstream << stream.rdbuf();
- str = stringstream.str();
-
- // Create the DynamicMessage.
- const google::protobuf::Message *dynamic_msg_prototype =
- factory.GetPrototype(MESSAGE_CIDENT::descriptor());
- for(int i = 0; i < NUM_MESSAGES; i++)
- msg[i] = dynamic_msg_prototype->New();
- return true;
-}
-
-static void cleanup()
-{
- for(int i = 0; i < NUM_MESSAGES; i++)
- delete msg[i];
-}
-
-static size_t run(int i)
-{
- if(!msg[i%NUM_MESSAGES]->ParsePartialFromString(str)) {
- fprintf(stderr, "Error parsing with proto2.\n");
- return 0;
- }
- return str.size();
-}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback