forked from screeps/driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-pgo
executable file
·29 lines (25 loc) · 1.08 KB
/
run-pgo
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
#!/bin/bash
# Runs GCC or Clang (OS X) profiling instrumentation and compiles w/ profile-guided optimizations
set -e
node-gyp configure
rm -f build/Release/native.node
make V=1 BUILDTYPE=Release -C build
echo -e "\nTesting Release build now..."
time_o3=$(node profile.js Release)
make V=1 BUILDTYPE=Profile -C build
echo -e "\nRunning instrumentation now..."
node profile.js Profile >/dev/null
if [[ "$OSTYPE" == "darwin"* ]]; then
/usr/local/Cellar/llvm/$(brew list --versions llvm | awk '{print $2}')/bin/llvm-profdata merge -output _clangprof.profdata _clangprof.profraw
fi
make V=1 BUILDTYPE=Optimized -C build
echo -e "\nRe-running..."
time_optimized=$(node profile.js Optimized)
if [[ $(echo "$time_o3 > $time_optimized" | bc) -eq 1 ]]; then
echo "Looks good. Replacing release with optimized. "
echo "Improvement: $(echo "scale=2; $time_o3 * 100 / $time_optimized - 100" | bc)%"
cp build/Optimized/native.node build/Release/native.node
else
echo "Optimized build is slower! Leaving Release in place"
echo "Regression: $(echo "scale=2; $time_optimized * 100 / $time_o3 - 100" | bc)%"
fi