| Index: components/tracing/experiment/perf_cmp.py
|
| diff --git a/components/tracing/experiment/perf_cmp.py b/components/tracing/experiment/perf_cmp.py
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..91d846427c3998cdefecd9eae90992a34c753cbb
|
| --- /dev/null
|
| +++ b/components/tracing/experiment/perf_cmp.py
|
| @@ -0,0 +1,65 @@
|
| +#!/usr/bin/env python
|
| +# Copyright (c) 2017 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +
|
| +def read_perf(filename):
|
| + perf = {}
|
| + with open(filename, 'r') as f:
|
| + for line in f.readlines():
|
| + if not '*RESULT' in line:
|
| + continue
|
| + cat = line.split('TraceEventPerfTest.')[1].split('=')[0]
|
| + val = int(line.split('= ')[1].split(' ms')[0])
|
| + perf[cat] = val
|
| + return perf
|
| +
|
| +
|
| +# Excludes 5% interval at the range's ends.
|
| +def noisy_mean(arr):
|
| + length = len(arr)
|
| + margin = length / 20
|
| + arr_sorted = sorted(arr)
|
| + mean = 0
|
| + for i in range(margin, length - margin):
|
| + mean += arr_sorted[i]
|
| + mean /= length - 2 * margin
|
| + return mean
|
| +
|
| +
|
| +def main():
|
| + n_samples = 50
|
| + perf_keys = list(read_perf('data/tot_1.log').keys())
|
| + perf_tot = {}
|
| + perf_old = {}
|
| + for cat in perf_keys:
|
| + perf_tot[cat] = []
|
| + perf_old[cat] = []
|
| +
|
| + for i in range(1, n_samples + 1):
|
| + tot = read_perf('data/tot_{0}.log'.format(i))
|
| + old = read_perf('data/old_{0}.log'.format(i))
|
| + for cat in perf_keys:
|
| + perf_tot[cat].append(tot[cat])
|
| + perf_old[cat].append(old[cat])
|
| +
|
| + for cat in perf_keys:
|
| + perf_tot[cat].sort()
|
| + perf_old[cat].sort()
|
| +
|
| + print cat
|
| + print perf_tot[cat]
|
| + print 'median(tot)=', perf_tot[cat][n_samples / 2]
|
| + print 'mean(tot)=', noisy_mean(perf_tot[cat])
|
| + print
|
| +
|
| + print perf_old[cat]
|
| + print 'median(old)=', perf_old[cat][n_samples / 2]
|
| + print 'mean(old)=', noisy_mean(perf_old[cat])
|
| + print
|
| + print
|
| +
|
| +
|
| +if __name__ == '__main__':
|
| + main()
|
|
|