Skip to content
Snippets Groups Projects
Commit 0b2af228 authored by Cookiebowser's avatar Cookiebowser
Browse files

enhanced result processing script to calculate median

parent 9ff55e2a
Branches
No related tags found
1 merge request!28Rust support
...@@ -5,6 +5,11 @@ from datetime import timedelta ...@@ -5,6 +5,11 @@ from datetime import timedelta
file = sys.argv[1] file = sys.argv[1]
print('opening file: ', file) print('opening file: ', file)
full_print = True
if len(sys.argv) > 2 and sys.argv[2].upper() == 'SHORT':
print('argv2 provided')
full_print = False
# {machine: { (mode: str, threads: int, caching: bool): {times: [], memory: []} }} # {machine: { (mode: str, threads: int, caching: bool): {times: [], memory: []} }}
data = {} data = {}
...@@ -17,7 +22,7 @@ with open(file, 'r') as lines: ...@@ -17,7 +22,7 @@ with open(file, 'r') as lines:
machine, mode, threads, caching, time, memory = stripped_line.split(' ') machine, mode, threads, caching, time, memory = stripped_line.split(' ')
if machine not in data: if machine not in data:
data[machine] = {} data[machine] = {}
params = (mode, int(threads), caching == 'true') params = (mode, int(threads), caching.upper() == 'TRUE')
if params not in data[machine]: if params not in data[machine]:
data[machine][params] = {'times': [], 'memory': []} data[machine][params] = {'times': [], 'memory': []}
data[machine][params]['times'] += [time] data[machine][params]['times'] += [time]
...@@ -28,6 +33,7 @@ for machine in data.keys(): ...@@ -28,6 +33,7 @@ for machine in data.keys():
times = data[machine][params]['times'] times = data[machine][params]['times']
avg_time = timedelta() avg_time = timedelta()
number_of_datapoints = 0 number_of_datapoints = 0
parsed_times = []
for time in times: for time in times:
number_of_datapoints += 1 number_of_datapoints += 1
...@@ -44,10 +50,33 @@ for machine in data.keys(): ...@@ -44,10 +50,33 @@ for machine in data.keys():
time = split[0] time = split[0]
seconds = int(time) seconds = int(time)
avg_time += timedelta(minutes=minutes, seconds=seconds, milliseconds=millis) parsed_time = timedelta(minutes=minutes, seconds=seconds, milliseconds=millis)
if number_of_datapoints > 0: avg_time += parsed_time
parsed_times += [parsed_time]
parsed_times.sort()
if number_of_datapoints <= 0:
continue
avg_time /= number_of_datapoints avg_time /= number_of_datapoints
median_time = parsed_times[len(parsed_times) // 2]
if len(parsed_times) % 2 == 0:
median_time = (median_time + parsed_times[len(parsed_times) // 2 + 1]) / 2
memories = data[machine][params]['memory'] memories = data[machine][params]['memory']
memories.sort()
median_memory = memories[len(memories) // 2]
if len(memories) % 2 == 0:
median_memory = (median_memory + memories[len(memories) // 2 + 1]) / 2
print(f'{machine} {params[0]} {params[1]} {params[2]} {round(avg_time.total_seconds(), 2)} {round(statistics.fmean(memories))}') spacing = " "*(len(machine) + len(params[0]) + len(str(params[1])) + len(str(params[2])) - 5)
print(f'{machine} {params[0]} {params[1]} {params[2]} {round(median_time.total_seconds(), 2)} {round(median_memory)}')
if full_print:
print( f'{spacing}time : min {round(parsed_times[0].total_seconds(), 2)}, '
f'median: {round(median_time.total_seconds(), 2)}, '
f'average: {round(avg_time.total_seconds(), 2)}, '
f'max: {round(parsed_times[-1].total_seconds(), 2)}')
print( f'{spacing}memory: min {round(memories[0])}, '
f'median: {round(median_memory)}, '
f'average: {round(statistics.fmean(memories))}, '
f'max: {round(memories[-1])}')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment