-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added benchmark plots, amended RooFitBinned benchmarks, and added bas…
…h script
- Loading branch information
Abhigyan Acherjee
authored and
Abhigyan Acherjee
committed
Mar 4, 2024
1 parent
d479d99
commit eb1b2fc
Showing
4 changed files
with
157 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import pandas as pd | ||
import csv | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
def parse_and_writer(csv_file_path,name): | ||
with open(csv_file_path, 'r', newline='') as csvfile: | ||
reader = csv.reader(csvfile) | ||
for _ in range(8): | ||
next(reader) | ||
|
||
filtered_csv_file_path=""+name+".csv" | ||
with open(filtered_csv_file_path, 'w', newline='') as filtered_csvfile: | ||
writer = csv.writer(filtered_csvfile) | ||
for row in reader: | ||
writer.writerow(row) | ||
|
||
parse_and_writer("./out_codegen.csv","codegen") | ||
parse_and_writer("./out_codegen_ngrad.csv","codegen_ngrad") | ||
parse_and_writer("./out_cpu.csv","cpu") | ||
parse_and_writer("./out_legacy.csv","legacy") | ||
|
||
codegen_df=pd.read_csv("codegen.csv") | ||
codegen_nograd_df=pd.read_csv("codegen_ngrad.csv") | ||
legacy_df=pd.read_csv("legacy.csv") | ||
cpu_df=pd.read_csv("cpu.csv") | ||
|
||
|
||
|
||
# Plotting | ||
plt.figure(figsize=(10, 6)) | ||
|
||
x = np.arange(len(codegen_df['name'].unique())) | ||
|
||
|
||
|
||
for i, benchmark in enumerate(codegen_df['name'].unique()): | ||
|
||
codegen_time = codegen_df.loc[codegen_df['name'] == benchmark, 'real_time'] | ||
codegen_nograd_time = codegen_nograd_df.loc[codegen_nograd_df['name'] == benchmark, 'real_time'] | ||
cpu_time = cpu_df.loc[cpu_df['name'] == benchmark, 'real_time'] | ||
legacy_time = legacy_df.loc[legacy_df['name'] == benchmark, 'real_time'] | ||
|
||
plt.bar(x[i]-0.10, codegen_time, width=0.15, align='center', label='codegen',color='lightblue') | ||
plt.bar(x[i], codegen_nograd_time, width=0.15, align='edge', label='codegen_nograd',color='navy') | ||
plt.bar(x[i]+0.15, cpu_time, width=0.15, align='edge', label='cpu',color='cyan') | ||
plt.bar(x[i]+0.30, legacy_time, width=0.15, align='edge', label='legacy',color='gray') | ||
|
||
|
||
# Customize legend | ||
legend_labels = ['codegen', 'codegen_nograd', 'cpu','legacy'] | ||
legend_colors = ['lightblue', 'navy', 'cyan','gray'] | ||
legend_handles = [plt.Rectangle((0,0),1,1, color=color) for color in legend_colors] | ||
plt.legend(legend_handles, legend_labels) | ||
|
||
plt.yscale('log') | ||
|
||
plt.xlabel('Benchmark') | ||
plt.ylabel('Time (milliseconds)') | ||
plt.title('Comparison of Benchmarks for Different Evaluation Backends') | ||
plt.xticks(x, rotation=90) | ||
plt.tight_layout() | ||
plt.savefig('comparision_plot.jpg') | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Function to run a benchmark script and wait until the CSV file is generated | ||
# to make it executable chmod +x run_benchmarks.sh | ||
#then run it using ./run_benchmarks.sh | ||
#!/bin/bash | ||
|
||
# Function to run the benchmark command and wait for CSV file to be generated | ||
run_benchmark() { | ||
echo "Running benchmark: $1" | ||
$1 & | ||
local pid=$! | ||
while [ ! -f $2 ]; do | ||
sleep 1 | ||
done | ||
wait $pid | ||
echo "CSV file generated: $2" | ||
} | ||
|
||
# Run benchmarks | ||
run_benchmark "./benchRooFitBinned -b codegen --benchmark_out_format=csv --benchmark_out=out_codegen.csv" "out_codegen.csv" | ||
run_benchmark "./benchRooFitBinned -b codegen_no_grad --benchmark_out_format=csv --benchmark_out=out_codegen_ngrad.csv" "out_codegen_ngrad.csv" | ||
run_benchmark "./benchRooFitBinned -b legacy --benchmark_out_format=csv --benchmark_out=out_legacy.csv" "out_legacy.csv" | ||
run_benchmark "./benchRooFitBinned -b cpu --benchmark_out_format=csv --benchmark_out=out_cpu.csv" "out_cpu.csv" | ||
|
||
# Run Python script | ||
python3 compare_benchmarks.py |