[tools] Add script to convert telemetry json files for callstats.html

tools/callstats-from-telemetry.sh converts multiple telemetry results
form benchmark runs into a single callstats-compatible json file.

Change-Id: I775109d4274c2cf8d87797b73695497d82d59d4a
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2276043
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68630}
This commit is contained in:
Camillo Bruni 2020-06-30 14:17:52 +02:00 committed by Commit Bot
parent e6c22a06c9
commit 7b848f07ef
2 changed files with 82 additions and 1 deletions

View File

@ -0,0 +1,61 @@
#1/bin/env bash
set -e
usage() {
cat << EOF
usage: $0 OPTIONS RESULTS_DIR
Convert telemetry json trace result to callstats.html compatible
versions ot ./out.json
OPTIONS:
-h Show this message.
RESULTS_DIR tools/perf/artifacts/run_XXX
EOF
}
while getopts ":h" OPTION ; do
case $OPTION in
h) usage
exit 0
;;
?) echo "Illegal option: -$OPTARG"
usage
exit 1
;;
esac
done
# =======================================================================
RESULTS_DIR=$1
if [[ ! -e "$RESULTS_DIR" ]]; then
echo "RESULTS_DIR '$RESULTS_DIR' not found";
usage;
exit 1;
fi
OUT=out.json
if [[ -e $OUT ]]; then
cp --backup=numbered $OUT $OUT.bak
fi
echo '{ "telemetry-results": { "placeholder":{}' > $OUT
for PAGE_DIR in $RESULTS_DIR/*_1; do
PAGE=`basename $PAGE_DIR`;
JSON="$PAGE_DIR/trace/traceEvents/*_converted.json";
du -sh $JSON;
echo "Converting PAGE=$PAGE";
echo "," >> $OUT;
echo "\"$PAGE\": " >> $OUT;
jq '[.traceEvents[].args | select(."runtime-call-stats" != null) | ."runtime-call-stats"]' $JSON >> $OUT;
done
echo '}}' >> $OUT

View File

@ -2148,8 +2148,28 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
<div class="inline">
<h2>Usage</h2>
<ol>
<li>Install scipy, e.g. <code>sudo aptitude install python-scipy</code>
<li>Build chrome.</li>
</ol>
<h3>Telemetry benchmark</h3>
<ol>
<li>Run <code>v8.browsing</code> benchmarks:
<pre>$CHROMIUM_DIR/tools/perf/run_benchmark run v8.browsing_desktop \
--browser=exact --browser-executable=$CHROMIUM_DIR/out/release/chrome \
--story-filter='.*2020 ' \
--also-run-disabled-tests
</pre>
</li>
<li>Install <a href="https://stedolan.github.io/jq/">jq</a>.</li>
<li>Convert the telemetry JSON files to callstats JSON file:
<pre>
$V8_DIR/tools/callstats-from-telemetry.sh $CHROMIUM_DIR/tools/perf/artifacts/run_XXXX
</pre>
</li>
<li>Load the generated <code>out.json</code></li>
</ol>
<h3>Raw approach</h3>
<ol>
<li>Install scipy, e.g. <code>sudo aptitude install python-scipy</code>
<li>Check out a known working version of webpagereply:
<pre>git -C $CHROME_DIR/third_party/webpagereplay checkout 7dbd94752d1cde5536ffc623a9e10a51721eff1d</pre>
</li>