run_benchmark.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/sh
  2. git remote add upstream https://gitlab.redox-os.org/redox-os/ion.git
  3. git fetch upstream
  4. git checkout upstream/master
  5. cargo bench
  6. cargo build --release
  7. PREV_SIZE=$(ls -al target/release/ion | cut -d' ' -f5)
  8. git stash
  9. git checkout -
  10. cargo bench
  11. cargo build --release
  12. SIZE=$(ls -al target/release/ion | cut -d' ' -f5)
  13. # if lower_bound*upper_bound > 0, then we consider the benchmark "changed"
  14. NOISE=0.05
  15. JQ_FILTER="if .Median.confidence_interval.lower_bound > $NOISE or .Median.confidence_interval.upper_bound < -$NOISE then .Median.point_estimate else \"\" end"
  16. total=0
  17. total_worse=0
  18. result=""
  19. for suite in ./target/criterion/*; do
  20. name=$(echo $suite | cut -d'/' -f 4)
  21. worse=0
  22. tests=0
  23. testcases=""
  24. for test in $suite/*/*/change/estimates.json; do
  25. estimate=$(cat "$test" | jq -r "$JQ_FILTER" -c)
  26. if echo "$estimate" | grep -Eq '^[0-9]+\.?[0-9]*$'; then
  27. inner="<failure message=\"Performance Regressed\" type=\"WARNING\">\
  28. Performance regressed by $estimate in $test\
  29. </failure>"
  30. worse=$((worse+1))
  31. fi
  32. testcases="$testcases<testcase id=\"$(echo "$test" | cut -d'/' -f 6)\" name=\"$(echo "$test" | cut -d'/' -f 6)\">$inner</testcase>"
  33. tests=$((tests+1))
  34. done
  35. result="$result<testsuite id=\"$name\" name=\"$name\" tests=\"$tests\" failures=\"$worse\">$testcases</testsuite>"
  36. total_worse=$((total_worse + worse))
  37. total=$((total + tests))
  38. done
  39. binary=$(test $(echo "$PREV_SIZE * 105 / 100" | bc) -ge $SIZE; echo $?)
  40. result="$result\
  41. <testsuite id=\"size\" name=\"Binary size\" tests=\"1\" failures=\"$binary\">\
  42. <testcase id=\"size\" name=\"Binary size\">"
  43. total=$((total + 1))
  44. if [ ! "$binary" -eq "0" ]; then
  45. result="$result\
  46. <failure message=\"Binary size increased\" type=\"WARNING\">\
  47. Binary size increased from $PREV_SIZE to $SIZE.\
  48. </failure>"
  49. total_worse=$((total_worse + 1))
  50. fi
  51. result="$result</testcase></testsuite>"
  52. result="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
  53. <testsuites id=\"$(date +%s)\" name=\"Performances\" tests=\"$total\" failures=\"$total_worse\">
  54. $result
  55. </testsuites>"
  56. echo $result > target/report.xml
  57. test "$total_worse" -eq "0"