-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbench
executable file
·76 lines (65 loc) · 1.57 KB
/
bench
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
set -e
ulimit -t 1200
function checkFailedBuild {
if [[ $? != 0 ]]; then
echo "Build failed"
exit 1
fi
}
trap checkFailedBuild Exit
export BUNDLE_GEMFILE="$(pwd)/Gemfile"
bundle update
NUMBER_OF_RUNS=3
RESULTS="$(pwd)/results.csv"
if [[ ! -s $RESULTS ]]; then
echo "Jekyll version, user time in seconds, site" > $RESULTS
fi
if [[ -n $PR ]]; then
VERSION="#$PR"
elif [[ -n $BRANCH ]]; then
VERSION="$BRANCH"
elif [[ -n $REF ]]; then
VERSION="$REF"
else
VERSION="master"
fi
if command -v gtime; then
TIME=$(which gtime)
else
TIME=$(which time)
fi
# Create tmp/ directory
TMPDIR="$(pwd)/sites"
if [[ -d $TMPDIR ]]; then
rm -rf "$TMPDIR"
fi
mkdir -p "$TMPDIR/source"
mkdir -p "$TMPDIR/destination"
# Flush SASS cache
if [[ -d "$(pwd)/.sass-cache" ]]; then
rm -rf "$(pwd)/.sass-cache"
fi
# Create a directory for flamegraphs
if [[ -n $FLAMEGRAPH ]]; then
mkdir -p "docs/$REF"
fi
for SITE in $(cat "site-list"); do
echo "
________________________________________________________________________________
Sampling: $SITE"
SOURCE="$TMPDIR/source/${SITE##*/}"
DESTINATION=${SOURCE/source/destination}
SVG_PATH="docs/$REF/${SITE##*/}"
if [[ ! -d $SOURCE ]]; then
git clone --recurse-submodules -q "$SITE" "$SOURCE"
fi
for ((i=0; i<NUMBER_OF_RUNS; ++i)); do
"$TIME" -ao "$RESULTS" -f"$VERSION,%U,$SITE" \
bundle exec jekyll build -s "$SOURCE" -d "$DESTINATION" --trace
done
if [[ -n $FLAMEGRAPH ]]; then
rbspy record --file "$SVG_PATH" -- bundle exec jekyll build -s "$SOURCE" -d "$DESTINATION"
mv "$SVG_PATH" "$SVG_PATH.svg"
fi
done