diff --git a/tools/callstats-from-telemetry.sh b/tools/callstats-from-telemetry.sh index cea471cde8..3572b7e6ba 100755 --- a/tools/callstats-from-telemetry.sh +++ b/tools/callstats-from-telemetry.sh @@ -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 } diff --git a/tools/callstats.html b/tools/callstats.html index d00f48d8b5..2a797680bc 100644 --- a/tools/callstats.html +++ b/tools/callstats.html @@ -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. - \ No newline at end of file + diff --git a/tools/callstats.py b/tools/callstats.py index a5e6bfe69c..1b76d0c166 100755 --- a/tools/callstats.py +++ b/tools/callstats.py @@ -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