forked from google/pprof-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·74 lines (58 loc) · 1.93 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·74 lines (58 loc) · 1.93 KB
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
#!/bin/bash
SRCDIR="/cloned_src"
trap "cd $SRCDIR && npm run clean" EXIT
trap "echo '** TEST FAILED **'" ERR
function timeout_after() {
# timeout on Node 11 alpine image requires -t to specify time.
if [[ -f /bin/busybox ]] && [[ $(node -v) =~ ^v11.* ]]; then
timeout -t "${@}"
else
timeout "${@}"
fi
}
npm_install() {
timeout_after 60 npm install --quiet "${@}"
}
set -eox pipefail
cp -r /src "$SRCDIR"
cd "$SRCDIR"
. "tools/retry.sh"
NODEDIR=$(dirname $(dirname $(which node)))
retry npm_install --nodedir="$NODEDIR" \
${BINARY_HOST:+--pprof_binary_host_mirror=$BINARY_HOST} >/dev/null
npm run compile
npm pack --quiet
VERSION=$(node -e "console.log(require('./package.json').version);")
PROFILER="$PWD/pprof-$VERSION.tgz"
if [[ "$VERIFY_TIME_LINE_NUMBERS" == "true" ]]; then
BENCHDIR="$PWD/system-test/busybench-js"
BENCHPATH="src/busybench.js"
else
BENCHDIR="$PWD/system-test/busybench"
BENCHPATH="build/src/busybench.js"
fi
TESTDIR=$(mktemp -d)
cp -r "$BENCHDIR" "$TESTDIR/busybench"
cd "$TESTDIR/busybench"
retry npm_install typescript gts @types/node >/dev/null
retry npm_install --nodedir="$NODEDIR" \
$([ -z "$BINARY_HOST" ] && echo "--build-from-source=pprof" \
|| echo "--pprof_binary_host_mirror=$BINARY_HOST")\
"$PROFILER">/dev/null
if [[ "$VERIFY_TIME_LINE_NUMBERS" != "true" ]]; then
npm run compile
fi
node -v
node --trace-warnings "$BENCHPATH" 10 $VERIFY_TIME_LINE_NUMBERS
if [[ "$VERIFY_TIME_LINE_NUMBERS" == "true" ]]; then
pprof -lines -top -nodecount=2 time.pb.gz | tee $tty | \
grep "busyLoop.*src/busybench.js:[2-3][08-9]"
pprof -filefunctions -top -nodecount=2 heap.pb.gz | tee $tty | \
grep "busyLoop.*src/busybench.js"
else
pprof -filefunctions -top -nodecount=2 time.pb.gz | tee $tty | \
grep "busyLoop.*src/busybench.ts"
pprof -filefunctions -top -nodecount=2 heap.pb.gz | tee $tty | \
grep "busyLoop.*src/busybench.ts"
fi
echo '** TEST PASSED **'