Skip to content

Instantly share code, notes, and snippets.

@lopesivan
Forked from eguiraud/templight_root_profile.sh
Created October 12, 2018 00:24
Show Gist options
  • Save lopesivan/d9c1a869134df87d21e6b8c0fe6ae9e1 to your computer and use it in GitHub Desktop.
Save lopesivan/d9c1a869134df87d21e6b8c0fe6ae9e1 to your computer and use it in GitHub Desktop.
use templight to compile a root source and produce parsed profile info
#!/bin/bash
# N.B. requires gawk, recode, templight++ and templigt-convert to be in PATH
SRC="$1"
if [[ -z "${SRC}" ]]; then
exit 1
fi
FNAME=${SRC%.C}
FNAME=${FNAME%.cpp}
FNAME=${FNAME%.cxx}
# profile compilation executable
templight++ -Xtemplight -profiler -Xtemplight -ignore-system -c "$SRC" `root-config --cflags`
# convert trace to xml
templight-convert -f graphml "${FNAME}.o.trace.pbf" > "${FNAME}.xml"
# parse xml, output file contains two colums "TIME CONTEXT"
awk -F '[<>]' '/key="d1"/ { context=$3 } /key="d3"/ { if($3 != "0.000000000") { print $3, context } }' "${FNAME}.xml" | \
sort -k1 -r | recode html..ascii
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment