From 805174eda2356df1b01752c8bc57019e696e0a75 Mon Sep 17 00:00:00 2001 From: Yilun Chong Date: Tue, 10 Apr 2018 13:26:17 -0700 Subject: Add script for run and upload the benchmark result to bq --- kokoro/linux/benchmark/build.sh | 86 +++++++++++++++++++++++++++++++++++ kokoro/linux/benchmark/continuous.cfg | 11 +++++ 2 files changed, 97 insertions(+) create mode 100755 kokoro/linux/benchmark/build.sh create mode 100755 kokoro/linux/benchmark/continuous.cfg (limited to 'kokoro') diff --git a/kokoro/linux/benchmark/build.sh b/kokoro/linux/benchmark/build.sh new file mode 100755 index 00000000..b289290a --- /dev/null +++ b/kokoro/linux/benchmark/build.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# +# Change to repo root +cd $(dirname $0)/../../.. + +export OUTPUT_DIR=testoutput +oldpwd=`pwd` + +# tcmalloc +if [ ! -f gperftools/.libs/libtcmalloc.so ]; then + git clone https://github.com/gperftools/gperftools.git + cd gperftools + ./autogen.sh + ./configure + make -j8 + cd .. +fi + +# download datasets for benchmark +cd benchmarks +./download_data.sh +datasets=`find . -type f -name "dataset.*.pb"` +cd $oldpwd + +# build Python protobuf +./autogen.sh +./configure CXXFLAGS="-fPIC -O2 -fno-semantic-interposition" +make -j8 +cd python +python setup.py build --cpp_implementation +pip install . + +# build and run Python benchmark +cd ../benchmarks +make python-pure-python-benchmark +make python-cpp-reflection-benchmark +make -j8 python-cpp-generated-code-benchmark +echo "[" > tmp/python_result.json +echo "benchmarking pure python..." +./python-pure-python-benchmark --json --behavior_prefix="pure-python-benchmark" $datasets >> tmp/python_result.json +echo "," >> "tmp/python_result.json" +echo "benchmarking python cpp reflection..." +env LD_PRELOAD="$oldpwd/gperftools/.libs/libtcmalloc.so" ./python-cpp-reflection-benchmark --json --behavior_prefix="cpp-reflection-benchmark" $datasets >> tmp/python_result.json +echo "," >> "tmp/python_result.json" +echo "benchmarking python cpp generated code..." +env LD_PRELOAD="$oldpwd/gperftools/.libs/libtcmalloc.so" ./python-cpp-generated-code-benchmark --json --behavior_prefix="cpp-generated-code-benchmark" $datasets >> tmp/python_result.json +echo "]" >> "tmp/python_result.json" +cd $oldpwd + +# build CPP protobuf +./configure +make clean && make -j8 + +# build CPP benchmark +cd benchmarks +mv tmp/python_result.json . && make clean && make -j8 cpp-benchmark && mv python_result.json tmp +echo "benchmarking cpp..." +env LD_PRELOAD="$oldpwd/gperftools/.libs/libtcmalloc.so" ./cpp-benchmark --benchmark_min_time=5.0 --benchmark_out_format=json --benchmark_out="tmp/cpp_result.json" $datasets +cd $oldpwd + +# build go protobuf +export PATH="`pwd`/src:$PATH" +export GOPATH="$HOME/gocode" +mkdir -p "$GOPATH/src/github.com/google" +rm -f "$GOPATH/src/github.com/google/protobuf" +ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf" +export PATH="$GOPATH/bin:$PATH" +go get github.com/golang/protobuf/protoc-gen-go + +# build go benchmark +cd benchmarks +make go-benchmark +echo "benchmarking go..." +./go-benchmark $datasets > tmp/go_result.txt + +# build java benchmark +make java-benchmark +echo "benchmarking java..." +./java-benchmark -Cresults.file.options.file="tmp/java_result.json" $datasets + +# upload result to bq +make python_add_init +python util/run_and_upload.py -cpp="../tmp/cpp_result.json" -java="../tmp/java_result.json" \ + -python="../tmp/python_result.json" -go="../tmp/go_result.txt" + +cd $oldpwd diff --git a/kokoro/linux/benchmark/continuous.cfg b/kokoro/linux/benchmark/continuous.cfg new file mode 100755 index 00000000..a3558c65 --- /dev/null +++ b/kokoro/linux/benchmark/continuous.cfg @@ -0,0 +1,11 @@ +# Config file for running tests in Kokoro + +# Location of the build script in repository +build_file: "protobuf/kokoro/linux/benchmark/build.sh" +timeout_mins: 240 + +action { + define_artifacts { + regex: "**/sponge_log.xml" + } +} -- cgit v1.2.3