gprof.html
#
BEGIN {
print "HTML/Hiprof"
print " Contents
"
print "
"
print " Hierarchial Profile
"
print " Flat Profile
"
print "
"
}
function firstAlpha(naIndex)
{
for(naIndex=1; naIndex<=NF; ++naIndex) {
if($(naIndex)~"^[a-zA-Z_]") return naIndex;
}
}
{
if($0 ~ "^\[[0-9]") {
printf("\n", $1)
print $0
} else if ($0 ~ "]$") {
gsub(//, " ")
naIndex = firstAlpha()
pos = index($0, $(naIndex))
start_str = substr($0, 1, pos-1)
stop_str = substr($0, pos)
printf("%s %s \n", start_str, $NF, stop_str)
} else if ($0 ~ "^total " || $0 ~ "^ time ") {
printf(" %s\n",$0)
} else {
print $0
}
}
END {
print "
"
}