Fixed headers and updated benchmark script.

pull/13171/head
Joshua Haberman 4 years ago
parent bc200451ce
commit 358fa14d0e
  1. 24
      benchmarks/compare.py
  2. 1
      upb/decode.c
  3. 4
      upb/encode.c
  4. 1
      upb/json_decode.c
  5. 1
      upb/upb.h

@ -27,17 +27,17 @@ def GitWorktree(commit):
def Run(cmd): def Run(cmd):
subprocess.check_call(cmd, shell=True) 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" tmpfile = "/tmp/bench-output.json"
Run("rm -rf {}".format(tmpfile)) 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 bench_cpu:
if new: Run("CC=clang bazel build -c opt --copt=-march=native benchmarks:benchmark" + extra_args)
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("./bazel-bin/benchmarks/benchmark --benchmark_out_format=json --benchmark_out={} --benchmark_repetitions={}".format(tmpfile, runs)) Run("./bazel-bin/benchmarks/benchmark --benchmark_out_format=json --benchmark_out={} --benchmark_repetitions={}".format(tmpfile, runs))
with open(tmpfile) as f: with open(tmpfile) as f:
bench_json = json.load(f) bench_json = json.load(f)
@ -51,15 +51,13 @@ def Benchmark(outbase, bench_cpu=True, runs=12, new=False):
values = (name, run["iterations"], run["cpu_time"]) values = (name, run["iterations"], run["cpu_time"])
print("{} {} {} ns/op".format(*values), file=f) print("{} {} {} ns/op".format(*values), file=f)
if new: Run("CC=clang bazel build -c opt --copt=-g tests:conformance_upb" + extra_args)
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("cp -f bazel-bin/tests/conformance_upb {}.bin".format(outbase)) Run("cp -f bazel-bin/tests/conformance_upb {}.bin".format(outbase))
baseline = "master" baseline = "master"
bench_cpu = True bench_cpu = True
fasttable = False
if len(sys.argv) > 1: if len(sys.argv) > 1:
baseline = sys.argv[1] baseline = sys.argv[1]
@ -69,11 +67,11 @@ if len(sys.argv) > 1:
pass pass
# Benchmark our current directory first, since it's more likely to be broken. # 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. # Benchmark the baseline.
with GitWorktree(baseline): with GitWorktree(baseline):
Benchmark("/tmp/old", bench_cpu) Benchmark("/tmp/old", bench_cpu, fasttable=fasttable)
print() print()
print() print()

@ -1,6 +1,7 @@
#include "upb/decode.h" #include "upb/decode.h"
#include <setjmp.h>
#include <string.h> #include <string.h>
#include "upb/decode.int.h" #include "upb/decode.int.h"

@ -6,9 +6,11 @@
#include <string.h> #include <string.h>
#include "upb/msg.h" #include "upb/msg.h"
#include "upb/port_def.inc"
#include "upb/upb.h" #include "upb/upb.h"
/* Must be last. */
#include "upb/port_def.inc"
#define UPB_PB_VARINT_MAX_LEN 10 #define UPB_PB_VARINT_MAX_LEN 10
UPB_NOINLINE UPB_NOINLINE

@ -6,6 +6,7 @@
#include <inttypes.h> #include <inttypes.h>
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
#include <setjmp.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

@ -6,7 +6,6 @@
#define UPB_H_ #define UPB_H_
#include <assert.h> #include <assert.h>
#include <setjmp.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>

Loading…
Cancel
Save