Simple Runtime Analyzer
|
The plot.py
script is a Python utility designed to visualize performance analysis results generated by the Simple Runtime Analyzer C++ library. It reads and processes report files in CSV and JSON formats, producing an interactive scatter plot that illustrates the relationship between sample size and execution time. This tool provides a powerful visual aid for comparing the performance of different algorithms or data sets.
matplotlib
, allowing users to inspect data points and customize the view.The script is built with robust error handling to prevent crashes and provide clear feedback to the user. Before plotting, it performs a series of checks on the provided files.
❌ Error processing file file.csv: [error message]
. This ensures that the process continues even if some files are corrupted or malformed.❌ Error: No valid data files to plot
and terminate. This prevents the generation of an empty or meaningless plot.The script relies on pathlib
for file system operations and json
and csv
for data decoding, gracefully handling exceptions from these libraries.
The script uses matplotlib
to create a dynamic scatter plot, which is displayed in a separate, interactive window. This allows you to zoom in on specific data points, pan across the plot, and examine the data at various scales.
The script's built-in color palette contains six distinct colors. While it can theoretically handle any number of reports, the visualization is optimized for comparing up to six datasets at once. For more than six reports, the colors will repeat, which may reduce clarity. Each dataset is assigned a unique color and a legend entry for easy identification.
After the plot window is displayed, the script automatically saves the generated graph to a PNG file in the same directory as the input files. The naming convention for the output file is designed to be both descriptive and concise, adapting to the number of reports processed.
.png
extension.runtime_report.csv
→ runtime_report.png
report1.json, report2.csv, report3.txt
→ report1_report2_report3_comparison.png
report1.json, report2.csv, report3.txt, report4.csv, report5.json
→ report1_report2_report3_and_2_more_comparison.png