[tools] Fix callstats

- Remove debug printing in callstats.py
- Handle non-version nested JSON files better in callstats.html
- Harden RCS extraction from telemetry JSON files

Change-Id: Ied921e54e6281a456c0a6369d797c21785080036
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3471856
Reviewed-by: Marja Hölttä <marja@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79155}
This commit is contained in:
Camillo Bruni 2022-02-17 16:56:09 +01:00 committed by V8 LUCI CQ
parent 9bfa2aa6ad
commit 3ecb92e3b7
3 changed files with 23 additions and 18 deletions

View File

@ -46,7 +46,7 @@ fi
OUT=out.json
if [[ -e $OUT ]]; then
echo "# Creating backup for $OUT"
cp --backup=numbered $OUT $OUT.bak
cp $OUT $OUT.bak
fi
echo "# Writing to $OUT"
@ -54,11 +54,14 @@ echo "# Writing to $OUT"
function convert {
NAME=$1
JSON=$2
du -sh $JSON;
echo "Converting NAME=$NAME";
echo "," >> $OUT;
echo "\"$NAME\": " >> $OUT;
jq '[.traceEvents[].args | select(."runtime-call-stats" != null) | ."runtime-call-stats"]' $JSON >> $OUT;
# Check if any json file exists:
if ls $JSON 1> /dev/null 2>&1; then
du -sh $JSON;
echo "Converting NAME=$NAME";
echo "," >> $OUT;
echo "\"$NAME\": " >> $OUT;
jq '[.traceEvents[].args | select(."runtime-call-stats" != null) | ."runtime-call-stats"]' $JSON >> $OUT;
fi
}

View File

@ -1543,23 +1543,27 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
// Instead of the default multi-page JSON:
// {"Version 1": { "Page 1": ..., ...}, "Version 2": {...}, ...}
// In this case insert a single "Default" version as top-level entry.
let firstProperty = (object) => {
const firstProperty = (object) => {
for (let key in object) return object[key];
};
let maybePage = firstProperty(json);
let maybeMetrics = firstProperty(maybePage);
let tempName = name ? name : new Date().toISOString();
tempName = window.prompt('Enter a name for the loaded file:', tempName);
if ('count' in maybeMetrics && 'duration' in maybeMetrics) {
const maybeMetrics = firstProperty(json);
const maybeMetric = firstProperty(maybeMetrics);
const tempName = name ? name : new Date().toISOString();
const getFileName =
() => window.prompt('Enter a name for the loaded file:', tempName);
if ('count' in maybeMetric && 'duration' in maybeMetric) {
return {
[tempName]: json
[getFileName()]: json
}
}
// Legacy fallback where the metrics are encoded as arrays:
// { PAGE: [[metric_name, ...], [...], ]}
if (Array.isArray(maybeMetrics)) {
// Also, make sure we don't have the versioned array-style:
// { VERSION: { PAGE: [[metric_name, ...], [...], ]}, ...}
const innerArray = firstProperty(maybeMetrics);
if (Array.isArray(maybeMetric) && !Array.isArray(innerArray)) {
return {
[tempName]: json
[getFileName()]: json
}
}
return json
@ -2705,4 +2709,4 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
</div>
</body>
</html>
</html>

View File

@ -494,11 +494,9 @@ def print_stats(S, args):
def extract_domain(filename):
print(filename)
# Extract domain name: domain#123.txt or domain_123.txt
match = re.match(r'^(.*?)[^a-zA-Z]?[0-9]+?.txt', filename)
domain = match.group(1)
print(domain)
return domain