OILS / benchmarks / gperftools.sh View on Github | oilshell.org

60 lines, 29 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# benchmarks/gperftools.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10# Hm these appear to be ancient versions, google-pprof --version says 2.0, but
11# we're on 2.7
12#
13# https://github.com/gperftools/gperftools/releases
14
15uninstall() {
16 sudo apt remove google-perftools libgoogle-perftools-dev
17}
18
19# /usr/local/bin/pprof also seems to have the 2.0 version number!
20download() {
21 wget --directory _deps \
22 'https://github.com/gperftools/gperftools/releases/download/gperftools-2.7/gperftools-2.7.tar.gz'
23}
24
25readonly OILS_CPP='_bin/oils-for-unix.tcmalloc '
26
27collect-small() {
28 HEAPPROFILE=_tmp/small-parse.hprof $OILS_CPP -c 'echo hi'
29
30 echo 'echo hi' > _tmp/h.sh
31 HEAPPROFILE=_tmp/small-eval.hprof $OILS_CPP -n _tmp/h.sh
32}
33
34collect-big() {
35 #local path=benchmarks/testdata/configure
36 local path=${1:-configure}
37
38 HEAPPROFILE=_tmp/big-parse.hprof $OILS_CPP --ast-format none -n $path
39
40 # Run 200 iterations of fib(44). Got about 18 MB of heap usage.
41 # (This matches the 200 iterations in benchmarks/compute.sh, which shows 60
42 # MB max RSS)
43 HEAPPROFILE=_tmp/big-eval.hprof $OILS_CPP benchmarks/compute/fib.sh 200 44
44}
45
46# e.g. pass _tmp/osh_parse.hprof.0001.heap
47browse() {
48 ### Open it in a browser
49 pprof --web $OILS_CPP "$@"
50}
51
52svg() {
53 local in=$1
54 local out=${in%.heap}.svg
55 pprof --svg $OILS_CPP "$@" > $out
56
57 echo "Wrote $out"
58}
59
60"$@"