Skip to content

Commit

Permalink
fixed division by 0 in compare performance results (#1523)
Browse files Browse the repository at this point in the history
* fixed division by 0 in compare performance results

Signed-off-by: dafnapension <[email protected]>

* fixed another zero division

Signed-off-by: dafnapension <[email protected]>

---------

Signed-off-by: dafnapension <[email protected]>
Co-authored-by: Elron Bandel <[email protected]>
  • Loading branch information
dafnapension and elronbandel authored Jan 21, 2025
1 parent bd7bcf0 commit f684a22
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions performance/compare_benchmark_performance_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,34 @@
print(f"use Mocked inference = {os.environ['UNITXT_MOCK_INFERENCE_MODE']}")

ratio1 = (
pr_perf["generate_benchmark_dataset_time"] - pr_perf["load_time_no_initial_ms"]
) / (
main_perf["generate_benchmark_dataset_time"] - main_perf["load_time_no_initial_ms"]
(pr_perf["generate_benchmark_dataset_time"] - pr_perf["load_time_no_initial_ms"])
/ (
main_perf["generate_benchmark_dataset_time"]
- main_perf["load_time_no_initial_ms"]
)
if (
main_perf["generate_benchmark_dataset_time"]
- main_perf["load_time_no_initial_ms"]
)
> 0
else 1
)
ratio2 = (
pr_perf["evaluation_time"] / main_perf["evaluation_time"]
if main_perf["evaluation_time"] > 0
else 1
)
ratio2 = pr_perf["evaluation_time"] / main_perf["evaluation_time"]
# Markdown table formatting

line1 = " What is Measured | Main Branch | PR Branch | PR/Main ratio \n"
line2 = "--------------------|-------------|-------------|---------------\n"
line3 = f" Total time | {main_perf['total_time']:>11} | {pr_perf['total_time']:>11} | {pr_perf['total_time']/main_perf['total_time']:.2f}\n"
line4 = f" Load time | {main_perf['load_time_no_initial_ms']:>11} | {pr_perf['load_time_no_initial_ms']:>11} | {pr_perf['load_time_no_initial_ms']/main_perf['load_time_no_initial_ms']:.2f}\n"
ratio_line4 = (
pr_perf["load_time_no_initial_ms"] / main_perf["load_time_no_initial_ms"]
if main_perf["load_time_no_initial_ms"] > 0
else 1
)
line4 = f" Load time | {main_perf['load_time_no_initial_ms']:>11} | {pr_perf['load_time_no_initial_ms']:>11} | {ratio_line4:.2f}\n"
line5 = f" DS Gen. inc. Load | {main_perf['generate_benchmark_dataset_time']:>11} | {pr_perf['generate_benchmark_dataset_time']:>11} | {pr_perf['generate_benchmark_dataset_time']/main_perf['generate_benchmark_dataset_time']:.2f}\n"
line6 = f" DS Gen. exc. Load | {round(main_perf['generate_benchmark_dataset_time']-main_perf['load_time_no_initial_ms'], 3):>11} | {round(pr_perf['generate_benchmark_dataset_time']-pr_perf['load_time_no_initial_ms'], 3):>11} | {ratio1:.2f}\n"
line7 = f" Inference time | {main_perf['inference_time']:>11} | {pr_perf['inference_time']:>11} | {pr_perf['inference_time']/main_perf['inference_time']:.2f}\n"
Expand Down

0 comments on commit f684a22

Please sign in to comment.