run.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/bin/bash
  2. #
  3. # Change to repo root
  4. cd $(dirname $0)/../../..
  5. export OUTPUT_DIR=testoutput
  6. oldpwd=`pwd`
  7. # tcmalloc
  8. if [ ! -f gperftools/.libs/libtcmalloc.so ]; then
  9. git clone https://github.com/gperftools/gperftools.git
  10. cd gperftools
  11. ./autogen.sh
  12. ./configure
  13. make -j8
  14. cd ..
  15. fi
  16. # download datasets for benchmark
  17. cd benchmarks
  18. ./download_data.sh
  19. datasets=$(for file in $(find . -type f -name "dataset.*.pb" -not -path "./tmp/*"); do echo "$(pwd)/$file"; done | xargs)
  20. echo $datasets
  21. cd $oldpwd
  22. # build Python protobuf
  23. ./autogen.sh
  24. ./configure CXXFLAGS="-fPIC -O2"
  25. make -j8
  26. cd python
  27. python setup.py build --cpp_implementation
  28. pip install . --user
  29. # build and run Python benchmark
  30. cd ../benchmarks
  31. make python-pure-python-benchmark
  32. make python-cpp-reflection-benchmark
  33. make -j8 python-cpp-generated-code-benchmark
  34. echo "[" > tmp/python_result.json
  35. echo "benchmarking pure python..."
  36. ./python-pure-python-benchmark --json --behavior_prefix="pure-python-benchmark" $datasets >> tmp/python_result.json
  37. echo "," >> "tmp/python_result.json"
  38. echo "benchmarking python cpp reflection..."
  39. env LD_PRELOAD="$oldpwd/gperftools/.libs/libtcmalloc.so" LD_LIBRARY_PATH="$oldpwd/src/.libs" ./python-cpp-reflection-benchmark --json --behavior_prefix="cpp-reflection-benchmark" $datasets >> tmp/python_result.json
  40. echo "," >> "tmp/python_result.json"
  41. echo "benchmarking python cpp generated code..."
  42. env LD_PRELOAD="$oldpwd/gperftools/.libs/libtcmalloc.so" LD_LIBRARY_PATH="$oldpwd/src/.libs" ./python-cpp-generated-code-benchmark --json --behavior_prefix="cpp-generated-code-benchmark" $datasets >> tmp/python_result.json
  43. echo "]" >> "tmp/python_result.json"
  44. cd $oldpwd
  45. # build CPP protobuf
  46. ./configure
  47. make clean && make -j8
  48. # build Java protobuf
  49. cd java
  50. mvn package
  51. cd ..
  52. # build CPP benchmark
  53. cd benchmarks
  54. mv tmp/python_result.json . && make clean && make -j8 cpp-benchmark && mv python_result.json tmp
  55. echo "benchmarking cpp..."
  56. 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
  57. cd $oldpwd
  58. # build go protobuf
  59. export PATH="`pwd`/src:$PATH"
  60. export GOPATH="$HOME/gocode"
  61. mkdir -p "$GOPATH/src/github.com/google"
  62. rm -f "$GOPATH/src/github.com/protocolbuffers/protobuf"
  63. ln -s "`pwd`" "$GOPATH/src/github.com/protocolbuffers/protobuf"
  64. export PATH="$GOPATH/bin:$PATH"
  65. go get github.com/golang/protobuf/protoc-gen-go
  66. # build go benchmark
  67. cd benchmarks
  68. make go-benchmark
  69. echo "benchmarking go..."
  70. ./go-benchmark $datasets > tmp/go_result.txt
  71. # build java benchmark
  72. make java-benchmark
  73. echo "benchmarking java..."
  74. ./java-benchmark -Cresults.file.options.file="tmp/java_result.json" $datasets
  75. make js-benchmark
  76. echo "benchmarking js..."
  77. ./js-benchmark $datasets --json_output=$(pwd)/tmp/node_result.json
  78. make -j8 generate_proto3_data
  79. proto3_datasets=$(for file in $datasets; do echo $(pwd)/tmp/proto3_data/${file#$(pwd)}; done | xargs)
  80. echo $proto3_datasets
  81. # build php benchmark
  82. make -j8 php-c-benchmark
  83. echo "benchmarking php_c..."
  84. ./php-c-benchmark $proto3_datasets --json --behavior_prefix="php_c" > tmp/php_c_result.json
  85. # upload result to bq
  86. make python_add_init
  87. env LD_LIBRARY_PATH="$oldpwd/src/.libs" python -m util.result_uploader -php_c="../tmp/php_c_result.json" \
  88. -cpp="../tmp/cpp_result.json" -java="../tmp/java_result.json" -go="../tmp/go_result.txt" -python="../tmp/python_result.json" -node="../tmp/node_result.json"
  89. cd $oldpwd