diff --git a/benchmarks/average_benchmark_results.py b/benchmarks/average_benchmark_results.py index 1dc064f31ba71af39e5d18ec44378045bbe1dbca..94d857097e4616ba7534aabd93e49e80a0dc61ff 100644 --- a/benchmarks/average_benchmark_results.py +++ b/benchmarks/average_benchmark_results.py @@ -5,6 +5,11 @@ from datetime import timedelta file = sys.argv[1] 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: []} }} data = {} @@ -17,7 +22,7 @@ with open(file, 'r') as lines: machine, mode, threads, caching, time, memory = stripped_line.split(' ') if machine not in data: data[machine] = {} - params = (mode, int(threads), caching == 'true') + params = (mode, int(threads), caching.upper() == 'TRUE') if params not in data[machine]: data[machine][params] = {'times': [], 'memory': []} data[machine][params]['times'] += [time] @@ -28,6 +33,7 @@ for machine in data.keys(): times = data[machine][params]['times'] avg_time = timedelta() number_of_datapoints = 0 + parsed_times = [] for time in times: number_of_datapoints += 1 @@ -44,10 +50,33 @@ for machine in data.keys(): time = split[0] seconds = int(time) - avg_time += timedelta(minutes=minutes, seconds=seconds, milliseconds=millis) - if number_of_datapoints > 0: - avg_time /= number_of_datapoints + parsed_time = timedelta(minutes=minutes, seconds=seconds, milliseconds=millis) + avg_time += parsed_time + parsed_times += [parsed_time] + + parsed_times.sort() + if number_of_datapoints <= 0: + continue + + 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.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])}')