Created
May 4, 2019 17:23
-
-
Save eleniums/ccf997a9c6b17d1f8b7594c4a8285567 to your computer and use it in GitHub Desktop.
Script to run pprof for a cpu profile.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# INSTRUCTIONS: | |
# Run benchmark tests first (test_bench.sh) to generate a cpu profile. | |
# First parameter of this script is the index to use (samples or cpu). | |
# USEFUL PPROF COMMANDS: | |
# top - Outputs the top entries (can also do top10 or top20 or topN where N is any number to limit results). | |
# list - Shows method code with flat and cum values. | |
# web - Visualize graph through web browser (need to `brew install graphviz`). | |
# help - List all commands with descriptions. | |
# cum is total cpu usage for the method and any methods it calls. | |
# flat is total cpu usage for the method only. | |
SAMPLE_INDEX=$1 | |
if [ -z "$SAMPLE_INDEX" ]; then | |
SAMPLE_INDEX=samples | |
fi | |
go tool pprof -sample_index=$SAMPLE_INDEX ./cpu.prof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment