-
Notifications
You must be signed in to change notification settings - Fork 221
/
summarize-time-trials
executable file
·50 lines (40 loc) · 1.7 KB
/
summarize-time-trials
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python3
import numpy
import pandas
def main():
# load results, then identify successful and skipped tests
frame = pandas.read_csv('build/time-trials.csv')
results = frame['resultType']
successes = results == 'SUCCESS'
skips = results == 'SKIPPED'
# report failed tests, if any
failures = frame[~(successes | skips)]
if not failures.empty:
print('failed tests:')
print(failures)
return
# aggregate multiple trials of each individual test method
frame['elapsedTime'] = frame['endTime'] - frame['startTime']
grouped = frame[successes].groupby(['className', 'name'])['elapsedTime']
# print very wide tables in full; assume user can scroll horizontally
pandas.set_option('display.width', None)
pandas.set_option('display.max_colwidth', -1)
# summarize distribution of elapsed times, including fine-grained
# percentiles at the upper (slowest) end
times = grouped.mean()
times.sort_values(inplace=True)
print('Overall distribution and percentiles of elapsed times:\n')
print(times.describe(percentiles=numpy.arange(.8, 1, .01)))
print('\n')
# print slowest individual tests, showing only those in the 95% percentile
# or higher (slower)
ranked_times = pandas.DataFrame(times)
ranked_times['percentRank'] = times.rank(pct=True)
elapsed_times = ranked_times['elapsedTime']
ranked_times['fractionOfTotal'] = elapsed_times / elapsed_times.sum()
is_slow = ranked_times['percentRank'] >= .95
slowest_tests = ranked_times[is_slow][::-1]
print('Slowest individual tests:')
print(slowest_tests.to_string(formatters={'percentRank': '{:.1%}'.format}))
if __name__ == '__main__':
main()