| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 | #!/bin/bash## Change to repo rootcd $(dirname $0)/../../..export OUTPUT_DIR=testoutputoldpwd=`pwd`# tcmallocif [ ! -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 benchmarkcd benchmarks./download_data.shdatasets=`find . -type f -name "dataset.*.pb"`cd $oldpwd# build Python protobuf./autogen.sh./configure CXXFLAGS="-fPIC -O2"make -j8cd pythonpython setup.py build --cpp_implementationpip install .# build and run Python benchmarkcd ../benchmarksmake python-pure-python-benchmarkmake python-cpp-reflection-benchmarkmake -j8 python-cpp-generated-code-benchmarkecho "[" > tmp/python_result.jsonecho "benchmarking pure python..."./python-pure-python-benchmark --json --behavior_prefix="pure-python-benchmark" $datasets  >> tmp/python_result.jsonecho "," >> "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.jsonecho "," >> "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.jsonecho "]" >> "tmp/python_result.json"cd $oldpwd# build CPP protobuf./configuremake clean && make -j8# build CPP benchmarkcd benchmarksmv tmp/python_result.json . && make clean && make -j8 cpp-benchmark && mv python_result.json tmpecho "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" $datasetscd $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 benchmarkcd benchmarksmake go-benchmarkecho "benchmarking go..."./go-benchmark $datasets > tmp/go_result.txt# build java benchmarkmake java-benchmarkecho "benchmarking java..."./java-benchmark -Cresults.file.options.file="tmp/java_result.json" $datasets# upload result to bqmake python_add_initpython 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
 |