Skip to content

Commit

Permalink
Fixed headers and updated benchmark script.
Browse files Browse the repository at this point in the history
  • Loading branch information
haberman committed Nov 12, 2020
1 parent bc20045 commit 358fa14
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
24 changes: 11 additions & 13 deletions benchmarks/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ def GitWorktree(commit):
def Run(cmd):
subprocess.check_call(cmd, shell=True)

def Benchmark(outbase, bench_cpu=True, runs=12, new=False):
def Benchmark(outbase, bench_cpu=True, runs=12, fasttable=False):
tmpfile = "/tmp/bench-output.json"
Run("rm -rf {}".format(tmpfile))
Run("CC=clang bazel test ...")
#Run("CC=clang bazel test ...")
if fasttable:
extra_args = " --//:fasttable_enabled=true"
else:
extra_args = ""

if bench_cpu:
if new:
Run("CC=clang bazel build -c opt --copt=-march=native --//:fasttable_enabled=true benchmarks:benchmark")
else:
Run("CC=clang bazel build -c opt --copt=-march=native benchmarks:benchmark")

Run("CC=clang bazel build -c opt --copt=-march=native benchmarks:benchmark" + extra_args)
Run("./bazel-bin/benchmarks/benchmark --benchmark_out_format=json --benchmark_out={} --benchmark_repetitions={}".format(tmpfile, runs))
with open(tmpfile) as f:
bench_json = json.load(f)
Expand All @@ -51,15 +51,13 @@ def Benchmark(outbase, bench_cpu=True, runs=12, new=False):
values = (name, run["iterations"], run["cpu_time"])
print("{} {} {} ns/op".format(*values), file=f)

if new:
Run("CC=clang bazel build -c opt --copt=-g --//:fasttable_enabled=true tests:conformance_upb")
else:
Run("CC=clang bazel build -c opt --copt=-g tests:conformance_upb")
Run("CC=clang bazel build -c opt --copt=-g tests:conformance_upb" + extra_args)
Run("cp -f bazel-bin/tests/conformance_upb {}.bin".format(outbase))


baseline = "master"
bench_cpu = True
fasttable = False

if len(sys.argv) > 1:
baseline = sys.argv[1]
Expand All @@ -69,11 +67,11 @@ def Benchmark(outbase, bench_cpu=True, runs=12, new=False):
pass

# Benchmark our current directory first, since it's more likely to be broken.
Benchmark("/tmp/new", bench_cpu, new=True)
Benchmark("/tmp/new", bench_cpu, fasttable=fasttable)

# Benchmark the baseline.
with GitWorktree(baseline):
Benchmark("/tmp/old", bench_cpu)
Benchmark("/tmp/old", bench_cpu, fasttable=fasttable)

print()
print()
Expand Down
1 change: 1 addition & 0 deletions upb/decode.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include "upb/decode.h"

#include <setjmp.h>
#include <string.h>

#include "upb/decode.int.h"
Expand Down
4 changes: 3 additions & 1 deletion upb/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
#include <string.h>

#include "upb/msg.h"
#include "upb/port_def.inc"
#include "upb/upb.h"

/* Must be last. */
#include "upb/port_def.inc"

#define UPB_PB_VARINT_MAX_LEN 10

UPB_NOINLINE
Expand Down
1 change: 1 addition & 0 deletions upb/json_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <setjmp.h>
#include <stdlib.h>
#include <string.h>

Expand Down
1 change: 0 additions & 1 deletion upb/upb.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define UPB_H_

#include <assert.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
Expand Down

0 comments on commit 358fa14

Please sign in to comment.