Skip to content
This repository was archived by the owner on Nov 28, 2020. It is now read-only.

Commit 3d788c2

Browse files
authored
Prototype for running a subset of benchmarks on a pull request (#58)
Benchmarking: Commit script for running subset of benchmarks to test a PR Squashing commits: * Adding prototype for running test against a pr * Setting to use default RUNS too * Addressing points and also setting default runs to 30 to match the scripts in node/benchmark * Updating usage * Rework to make it less hacky
1 parent a8752fd commit 3d788c2

File tree

1 file changed

+97
-0
lines changed
  • experimental/benchmarks/community-benchmark

1 file changed

+97
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/bash
2+
function mandatory() {
3+
if [ -z "${!1}" ]; then
4+
echo "${1} not set"
5+
usage
6+
exit
7+
fi
8+
}
9+
10+
function optional() {
11+
if [ -z "${!1}" ]; then
12+
echo -n "${1} not set (ok)"
13+
if [ -n "${2}" ]; then
14+
echo -n ", default is: ${2}"
15+
export ${1}="${2}"
16+
fi
17+
echo ""
18+
fi
19+
}
20+
function usage(){
21+
echo "Usage:"
22+
23+
echo "This script has two use cases:"
24+
echo "Use case 1: We want to test the impact of a PR on a branch."
25+
echo "To run this, declare:"
26+
echo "The script expects the following variables to be set:"
27+
echo "CATEGORY = a category of tests to run - folders in benchmark/"
28+
echo "BRANCH = the branch the test should be based off. e.g. master"
29+
echo "PULL_ID = the pull request that contains changes to test"
30+
echo "-------------------------------------------------------------"
31+
echo "Use case 2: We want to compare two branches, tags or commits."
32+
echo "To run this, declare:"
33+
echo "CATEGORY = a category of tests to run - folders in benchmark/"
34+
echo "BASE = the branch/tag/commit the test should be based off. e.g. master"
35+
echo "TARGET = the branch/tag/commit to compare against base"
36+
echo "-------------------------------------------------------------"
37+
echo "The following are optional across both use cases"
38+
echo "RUNS = defaults to empty"
39+
echo "FILTER = defaults to empty"
40+
echo "MACHINE_THREADS - used for building node. Defaults to all threads on machine"
41+
42+
}
43+
44+
if [ -z $PULL_ID ]; then
45+
#PULL_ID isn't declared. Therefore we are probably in use case #2
46+
export USE_CASE=2
47+
mandatory BASE
48+
mandatory TARGET
49+
else
50+
export USE_CASE=1
51+
mandatory BRANCH
52+
mandatory PULL_ID
53+
fi
54+
mandatory CATEGORY
55+
optional RUNS
56+
optional FILTER
57+
getMACHINE_THREADS=`cat /proc/cpuinfo |grep processor|tail -n1|awk {'print $3'}`
58+
let getMACHINE_THREADS=getMACHINE_THREADS+1 #getting threads this way is 0 based. Add one
59+
optional MACHINE_THREADS $getMACHINE_THREADS
60+
rm -rf node
61+
git clone http://github.com/nodejs/node.git
62+
cd node
63+
case $USE_CASE in
64+
1)
65+
git checkout $BRANCH
66+
;;
67+
2)
68+
git checkout $BASE
69+
;;
70+
esac
71+
72+
# build master
73+
./configure
74+
make -j${MACHINE_THREADS}
75+
mv out/Release/node ./node-master
76+
77+
# build pr
78+
case $USE_CASE in
79+
1)
80+
curl https://patch-diff.githubusercontent.com/raw/nodejs/node/pull/${PULL_ID}.patch|git apply
81+
;;
82+
2)
83+
git checkout $TARGET
84+
;;
85+
esac
86+
./configure
87+
make -j${MACHINE_THREADS}
88+
mv out/Release/node ./node-pr
89+
if [ -n "$FILTER" ]; then
90+
FILTER="--filter ${FILTER}"
91+
fi
92+
if [ -n "$RUNS" ]; then
93+
RUNS="--runs ${RUNS}"
94+
fi
95+
# run benchmark
96+
./node-master benchmark/compare.js --old ./node-master --new ./node-pr $FILTER $RUNS -- $CATEGORY | tee output.csv
97+
cat output.csv | Rscript benchmark/compare.R

0 commit comments

Comments
 (0)