Commit c80f2bf8 authored by mlippautz's avatar mlippautz Committed by Commit bot

[tools] Beef up GC eval scripts

* Add csv output mode for spreadsheet pasting
* Add option to leave out top-level categories
* Deal with unknown categories

R=hpayer@chromium.org
LOG=N
BUG=
NOTRY=true

Review URL: https://codereview.chromium.org/1846983002

Cr-Commit-Position: refs/heads/master@{#35168}
parent b295462e
......@@ -74,10 +74,11 @@ class Histogram:
class Category:
def __init__(self, key, histogram):
def __init__(self, key, histogram, csv):
self.key = key
self.values = []
self.histogram = histogram
self.csv = csv
def process_entry(self, entry):
if self.key in entry:
......@@ -92,18 +93,29 @@ class Category:
return max(self.values)
def avg(self):
if len(self.values) == 0:
return 0.0
return sum(self.values) / len(self.values)
def __str__(self):
ret = [self.key]
ret.append(" len: {0}".format(len(self.values)))
if len(self.values) > 0:
ret.append(" min: {0}".format(min(self.values)))
ret.append(" max: {0}".format(max(self.values)))
ret.append(" avg: {0}".format(sum(self.values) / len(self.values)))
if self.histogram:
ret.append(str(self.histogram))
return "\n".join(ret)
if self.csv:
ret = [self.key]
ret.append(len(self.values))
ret.append(self.min())
ret.append(self.max())
ret.append(self.avg())
ret = [str(x) for x in ret]
return ",".join(ret)
else:
ret = [self.key]
ret.append(" len: {0}".format(len(self.values)))
if len(self.values) > 0:
ret.append(" min: {0}".format(self.min()))
ret.append(" max: {0}".format(self.max()))
ret.append(" avg: {0}".format(self.avg()))
if self.histogram:
ret.append(str(self.histogram))
return "\n".join(ret)
def __repr__(self):
return "<Category: {0}>".format(self.key)
......@@ -143,6 +155,8 @@ def main():
type=str, nargs='?',
default="no",
help="rank keys by metric (default: no)")
parser.add_argument('--csv', dest='csv',
action='store_true', help='provide output as csv')
args = parser.parse_args()
histogram = None
......@@ -154,7 +168,7 @@ def main():
bucket_trait = LinearBucket(args.linear_histogram_granularity)
histogram = Histogram(bucket_trait, not args.histogram_omit_empty)
categories = [ Category(key, deepcopy(histogram))
categories = [ Category(key, deepcopy(histogram), args.csv)
for key in args.keys ]
while True:
......
......@@ -7,47 +7,73 @@
# Convenience Script used to rank GC NVP output.
print_usage_and_die() {
echo "Usage: $0 RANK SORT [LOGFILE]"
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Arguments:"
echo " RANK: old-gen-rank | new-gen-rank"
echo " SORT: max | avg"
echo " LOGFILE: the file to process. will default to /dev/stdin"
echo "OPTIONS"
echo " -r|--rank new-gen-rank|old-gen-rank GC mode to profile"
echo " (default: old-gen-rank)"
echo " -s|--sort avg|max sorting mode (default: max)"
echo " -t|--top-level include top-level categories"
echo " -c|--csv provide csv output"
echo " -f|--file FILE profile input in a file"
echo " (default: stdin)"
exit 1
}
if [[ $# -lt 2 || $# -gt 3 ]]; then
print_usage_and_die
fi
case $1 in
new-gen-rank|old-gen-rank)
OP=$1
;;
*)
print_usage_and_die
esac
OP=old-gen-rank
RANK_MODE=max
TOP_LEVEL=no
CSV=""
LOGFILE=/dev/stdin
case $2 in
max|avg)
RANK_MODE=$2
;;
*)
print_usage_and_die
esac
while [[ $# -ge 1 ]]
do
key="$1"
case $key in
-r|--rank)
case $2 in
new-gen-rank|old-gen-rank)
OP="$2"
;;
*)
print_usage_and_die
esac
shift
;;
-s|--sort)
case $2 in
max|avg)
RANK_MODE=$2
;;
*)
print_usage_and_die
esac
shift
;;
-t|--top-level)
TOP_LEVEL=yes
;;
-c|--csv)
CSV=" --csv "
;;
-f|--file)
LOGFILE=$2
shift
;;
*)
break
;;
esac
shift
done
if [ $# -eq 3 ]; then
LOGFILE=$3
else
LOGFILE=/dev/stdin
if [[ $# -ne 0 ]]; then
echo "Unknown option(s): $@"
echo ""
print_usage_and_die
fi
GENERAL_INTERESTING_KEYS="\
pause \
"
INTERESTING_NEW_GEN_KEYS="\
${GENERAL_INTERESTING_KEYS} \
scavenge \
weak \
roots \
......@@ -58,8 +84,6 @@ INTERESTING_NEW_GEN_KEYS="\
"
INTERESTING_OLD_GEN_KEYS="\
${GENERAL_INTERESTING_KEYS} \
clear \
clear.code_flush \
clear.dependent_code \
clear.global_handles \
......@@ -70,8 +94,6 @@ INTERESTING_OLD_GEN_KEYS="\
clear.weak_cells \
clear.weak_collections \
clear.weak_lists \
finish \
evacuate \
evacuate.candidates \
evacuate.clean_up \
evacuate.copy \
......@@ -85,7 +107,6 @@ INTERESTING_OLD_GEN_KEYS="\
external.mc_incremental_prologue \
external.mc_incremental_epilogue \
external.weak_global_handles \
mark \
mark.finish_incremental \
mark.prepare_code_flush \
mark.roots \
......@@ -94,13 +115,27 @@ INTERESTING_OLD_GEN_KEYS="\
mark.weak_closure.weak_handles \
mark.weak_closure.weak_roots \
mark.weak_closure.harmony \
sweep \
sweep.code \
sweep.map \
sweep.old \
incremental_finalize \
"
if [[ "$TOP_LEVEL" = "yes" ]]; then
INTERESTING_OLD_GEN_KEYS="\
${INTERESTING_OLD_GEN_KEYS} \
clear \
evacuate \
finish \
incremental_finalize \
mark \
pause
sweep \
"
INTERESTING_NEW_GEN_KEYS="\
${INTERESTING_NEW_GEN_KEYS} \
"
fi
BASE_DIR=$(dirname $0)
case $OP in
......@@ -109,6 +144,7 @@ case $OP in
| $BASE_DIR/eval_gc_nvp.py \
--no-histogram \
--rank $RANK_MODE \
$CSV \
${INTERESTING_NEW_GEN_KEYS}
;;
old-gen-rank)
......@@ -116,9 +152,9 @@ case $OP in
| $BASE_DIR/eval_gc_nvp.py \
--no-histogram \
--rank $RANK_MODE \
$CSV \
${INTERESTING_OLD_GEN_KEYS}
;;
*)
;;
esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment