Skip to content

Instantly share code, notes, and snippets.

@dayeol
Created August 7, 2020 17:27
Show Gist options
  • Select an option

  • Save dayeol/95cf3d68fc3d162cd6345a1331e69578 to your computer and use it in GitHub Desktop.

Select an option

Save dayeol/95cf3d68fc3d162cd6345a1331e69578 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
NOW=$(date +"%Y-%m-%d-%H:%M:%S")
PERFDATA="perf.script"
INDIR=$1
NAME=$2
OUTDIR="$(pwd)/results/$2.$NOW"
STACKCOLLAPSE=~/FlameGraph/stackcollapse-perf.pl
FLAMEGRAPH=~/FlameGraph/flamegraph.pl
if [ ! -f "$INDIR/$PERFDATA" ]; then
echo "$INDIR/$PERFDATA does not exist!";
exit -1;
fi
# move perf output data
echo "Generating $OUTDIR"
mkdir -p $OUTDIR
sudo chown $USER:$USER $INDIR/$PERFDATA
sudo cp $INDIR/perf.* $OUTDIR/
sudo chown root:root $OUTDIR/$PERFDATA
cd $OUTDIR; cat $PERFDATA | \
$STACKCOLLAPSE --all --addrs | \
$FLAMEGRAPH > $OUTDIR/$NAME.svg
echo "Download:"
echo " scp $USER@mehlow-prequal06.jf.intel.com:$OUTDIR/$NAME.svg ."
cd -
# remove original files
sudo rm $INDIR/perf.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment