Make benchmark run out-of-the-box.

pull/13171/head
Joshua Haberman 16 years ago
parent 9bc15a1e74
commit 4d9c39b94d
  1. 13
      Makefile
  2. 6
      benchmark/benchmark.cc
  3. 2
      src/upb_context.c
  4. 2
      src/upb_parse.h

@ -3,10 +3,11 @@
CC=gcc
CXX=g++
CFLAGS=-std=c99
CPPFLAGS=-O3 -Wall -Wextra -pedantic -g -DUPB_UNALIGNED_READS_OK -fomit-frame-pointer -Idescriptor -Isrc
CPPFLAGS=-O3 -Wall -Wextra -pedantic -g -DUPB_UNALIGNED_READS_OK -fomit-frame-pointer -Idescriptor -Isrc -Itests
OBJ=src/upb_parse.o src/upb_table.o src/upb_msg.o src/upb_enum.o src/upb_context.o \
src/upb_string.o descriptor/descriptor.o
ALL=$(OBJ) src/libupb.a tests/test_table tests/tests tools/upbc
SRC=src/*.c src/*.h descriptor/*.c descriptor/*.h tests/*.c tests/*.h tools/*.c tools/*.h
ALL=$(OBJ) src/libupb.a tests/test_table tests/tests tools/upbc benchmark/benchmark
all: $(ALL)
clean:
rm -f $(ALL) deps
@ -15,8 +16,10 @@ src/libupb.a: $(OBJ)
ar rcs src/libupb.a $(OBJ)
tests/test_table: src/libupb.a
tools/upbc: src/libupb.a
benchmark/benchmark: src/libupb.a -lm
benchmark/benchmark: src/libupb.a benchmark/google_messages.pb.h -lm
benchmark/google_messages.pb.h benchmark/google_messages.pb: benchmark/google_messages.proto
protoc benchmark/google_messages.proto --cpp_out=. -obenchmark/google_messages.proto.pb
-include deps
deps: src/*.c src/*.h descriptor/*.c descriptor/*.h tests/*.c tests/*.h tools/*.c tools/*.h
gcc -MM *.c > deps
deps: $(SRC)
gcc -MM $(SRC) > deps

@ -1,6 +1,6 @@
#include <time.h>
#include "google_speed.pb.h"
#include "google_messages.pb.h"
#include "test_util.h"
#include "upb_context.h"
#include "upb_msg.h"
@ -10,7 +10,7 @@ int main ()
struct upb_context c;
upb_context_init(&c);
struct upb_string fds;
if(!upb_strreadfile("google_messages.proto.bin", &fds)) {
if(!upb_strreadfile("benchmark/google_messages.proto.pb", &fds)) {
fprintf(stderr, "Couldn't read google_speed.proto.bin.\n");
return 1;
}
@ -36,7 +36,7 @@ int main ()
upb_msg_parse_init(&s, data, m, false, true);
size_t read;
struct upb_string str;
if(!upb_strreadfile("google_message2.dat", &str)) {
if(!upb_strreadfile("benchmark/google_message2.dat", &str)) {
fprintf(stderr, "Error reading google_message2.dat\n");
return 1;
}

@ -272,7 +272,7 @@ bool upb_context_addfd(struct upb_context *c,
bool upb_context_parsefds(struct upb_context *c, struct upb_string *fds_str) {
google_protobuf_FileDescriptorSet *fds =
upb_alloc_and_parse(c->fds_msg, fds_str, true);
upb_alloc_and_parse(c->fds_msg, fds_str, false);
if(!fds) return false;
if(fds->set_flags.has.file) {

@ -104,7 +104,9 @@ typedef void (*upb_submsg_end_cb)(struct upb_parse_state *s);
* where user_data has as many bytes allocated as specified when initialized. */
struct upb_parse_stack_frame {
size_t end_offset; /* 0 indicates that this is a group. */
#ifndef __cplusplus /* Temporary hack since C++ doesn't support flex arrays. */
char user_data[];
#endif
};
struct upb_parse_state {

Loading…
Cancel
Save