Add heap-profiling script
This commit is contained in:
parent
908b102786
commit
533aaa462b
2 changed files with 76 additions and 0 deletions
34
script/heap-profile
Executable file
34
script/heap-profile
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Usage:
|
||||
# script/heap-profile
|
||||
#
|
||||
# Parse an example source file and record memory usage
|
||||
#
|
||||
# Dependencies:
|
||||
# * `pprof` executable: https://github.com/google/pprof
|
||||
# * `gperftools` package: https://github.com/gperftools/gperftools
|
||||
|
||||
set -e
|
||||
|
||||
GRAMMARS_DIR=$PWD/test/fixtures/grammars
|
||||
|
||||
# Build the library
|
||||
make
|
||||
|
||||
# Build the heap-profiling harness
|
||||
clang++ \
|
||||
-I lib/include \
|
||||
-I $GRAMMARS_DIR \
|
||||
-D GRAMMARS_DIR=\"${GRAMMARS_DIR}/\" \
|
||||
-l tcmalloc \
|
||||
./libtree-sitter.a \
|
||||
test/profile/heap.cc \
|
||||
-o target/heap-profile
|
||||
|
||||
# Run the harness with heap profiling enabled.
|
||||
export HEAPPROFILE=$PWD/profile
|
||||
target/heap-profile $@
|
||||
|
||||
# Extract statistics using pprof.
|
||||
pprof -top -cum profile.0001.heap
|
||||
Loading…
Add table
Add a link
Reference in a new issue