benchmark.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash
  2. RUN_TIMES=27
  3. tmpdir=$(mktemp --tmpdir -d clsync-hl-bench.XXXXXXXXXX)
  4. configuration() {
  5. git checkout -- configuration.h
  6. for regex in $@; do
  7. sed -i configuration.h -e "$regex"
  8. done
  9. }
  10. configure() {
  11. ./configure -C $@ >/dev/null 2>/dev/null || ./configure $@ || exit 1
  12. }
  13. run() {
  14. time ./clsync -Mso -S'doc/devel/thread-splitting/benchmark-synchandler.so' --have-recursive-sync --max-iterations 1 -W ~/clsync-test $@ || exit 1
  15. }
  16. benchmark() {
  17. make clean all
  18. HL_INITIAL=$(awk '{if ($2 == "HL_LOCK_TRIES_INITIAL") print $3}' < configuration.h)
  19. HL_AUTO=$(gcc -x c - -o "$tmpdir/hl_auto.bin" << 'EOF'
  20. #include <stdio.h>
  21. #include "configuration.h"
  22. int main() {
  23. #ifdef HL_LOCK_TRIES_AUTO
  24. printf("auto\n");
  25. #else
  26. printf("noauto\n");
  27. #endif
  28. return 0;
  29. }
  30. EOF
  31. "$tmpdir/hl_auto.bin"
  32. rm -f "$tmpdir/hl_auto.bin"
  33. )
  34. CONFIGURE=$(awk '{if ($2 == "./configure") {$1=""; $2="";print $0; exit}}' < config.log)
  35. hash="$*|$CONFIGURE"
  36. if [[ "$HL_AUTO" == "auto" ]]; then
  37. hash="$hash|$HL_AUTO"
  38. else
  39. hash="$hash|$HL_INITIAL"
  40. fi
  41. i=0
  42. while [[ "$i" -lt "$RUN_TIMES" ]]; do
  43. run -d1 $@ >> "$tmpdir/benchmark.log-$hash" 2>> "$tmpdir/benchmark.errlog-$hash"
  44. i=$(( i + 1 ))
  45. done
  46. }
  47. gcc -I. -shared -o doc/devel/thread-splitting/benchmark-synchandler.so -fPIC -D_DEBUG_SUPPORT doc/devel/thread-splitting/benchmark-synchandler.c
  48. configuration 's|SLEEP_SECONDS.*$|SLEEP_SECONDS 0|g'
  49. for args in "" "--thread-splitting"; do
  50. #for args in "--thread-splitting"; do
  51. configure --enable-debug=yes
  52. benchmark $args
  53. configure --enable-highload-locks --enable-debug=no
  54. benchmark $args
  55. configure --enable-highload-locks --enable-debug=yes
  56. benchmark $args
  57. configure --enable-highload-locks --enable-debug=force
  58. benchmark $args
  59. done
  60. configure --enable-highload-locks --enable-debug=yes
  61. benchmark
  62. interval=1;
  63. while [[ "$interval" -le "2147483648" ]]; do
  64. configuration 's|SLEEP_SECONDS.*$|SLEEP_SECONDS 0|g' 's|#define HL_LOCK_TRIES_AUTO|//#define HL_LOCK_TRIES_AUTO|g' "s|HL_LOCK_TRIES_INITIAL.*$|HL_LOCK_TRIES_INITIAL $interval|g"
  65. benchmark --thread-splitting
  66. interval=$(( interval * 2 ))
  67. done
  68. rm -f doc/devel/thread-splitting/benchmark-synchandler.so