Skip to content

Commit

Permalink
improve scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
lvinci committed Apr 26, 2024
1 parent c9b4e66 commit 5b2d724
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
Binary file modified results/plots/m1pro/comp_all_partitions.pdf
Binary file not shown.
Binary file modified results/plots/m1pro/comp_all_threads.pdf
Binary file not shown.
51 changes: 31 additions & 20 deletions scripts/calculate_averages.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
#!/usr/bin/python3

import csv
import os
import sys

ATTEMPTS = 5

benchmarkId = sys.argv[1]
sourceFilepath = f'../results/benchmarks/{benchmarkId}/benchmark_results.csv'
destinationFile = open(f'../results/benchmarks/{benchmarkId}_averaged.csv', "w")

# Read in csv file
with open(sourceFilepath, newline="") as csvfile:
reader = csv.reader(csvfile, delimiter=",", quotechar="\"")
avgRuntime = 0.0
for line in reader:
# Read in the csv rows
threads = line[0]
partitions = line[1]
attempt = int(line[2])
runtime = float(line[3])
# Add to the average runtime add write it to the file when the 5th attempt is reached
avgRuntime += runtime
if attempt == ATTEMPTS:
avgRuntime /= ATTEMPTS
destinationFile.write(f'{threads},{partitions},{avgRuntime}\n')
avgRuntime = 0

destinationFile.close()
def generate_averages(benchmark_id):
source_filepath = f'../results/benchmarks/{benchmark_id}/benchmark_results.csv'
destination_file = open(f'../results/benchmarks/{benchmark_id}_averaged.csv', "w")
with open(source_filepath, newline="") as csvfile:
reader = csv.reader(csvfile, delimiter=",", quotechar="\"")
avg_runtime = 0.0
for line in reader:
# Read in the csv rows
threads = line[0]
partitions = line[1]
attempt = int(line[2])
runtime = float(line[3])
# Add to the average runtime add write it to the file when the 5th attempt is reached
avg_runtime += runtime
if attempt == ATTEMPTS:
avg_runtime /= ATTEMPTS
destination_file.write(f'{threads},{partitions},{avg_runtime}\n')
avg_runtime = 0
destination_file.close()


def main() -> int:
for benchmark_id in os.listdir("../results/benchmarks"):
if os.path.isdir(f'../results/benchmarks/{benchmark_id}'):
generate_averages(benchmark_id)
return 0


if __name__ == '__main__':
sys.exit(main())
9 changes: 5 additions & 4 deletions scripts/generate_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ def generate_comp_all_partitions_plot(benchmark_id: string, dataset: list[Datase


def main() -> int:
benchmark_id = sys.argv[1]
dataset = read_csv_dataset(f'../results/benchmarks/{benchmark_id}_averaged.csv')
generate_comp_all_threads_plot(benchmark_id, dataset)
generate_comp_all_partitions_plot(benchmark_id, dataset)
for benchmark_id in os.listdir("../results/benchmarks"):
if os.path.isdir(f'../results/benchmarks/{benchmark_id}'):
dataset = read_csv_dataset(f'../results/benchmarks/{benchmark_id}_averaged.csv')
generate_comp_all_threads_plot(benchmark_id, dataset)
generate_comp_all_partitions_plot(benchmark_id, dataset)
return 0


Expand Down

0 comments on commit 5b2d724

Please sign in to comment.