Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:17

0001 # SPDX-PackageName = "traccc, a part of the ACTS project"
0002 # SPDX-FileCopyrightText: CERN
0003 # SPDX-License-Identifier: MPL-2.0
0004 
0005 import matplotlib.pyplot
0006 import pandas
0007 import argparse
0008 import logging
0009 import pathlib
0010 from datetime import datetime
0011 
0012 log = logging.getLogger("traccc_plot")
0013 
0014 
0015 def main():
0016     parser = argparse.ArgumentParser()
0017 
0018     parser.add_argument(
0019         "input",
0020         type=pathlib.Path,
0021         help="input CSV database",
0022     )
0023 
0024     parser.add_argument(
0025         "output",
0026         type=pathlib.Path,
0027         help="output plot file",
0028     )
0029 
0030     parser.add_argument(
0031         "--threshold",
0032         type=float,
0033         help="value in seconds under which to hide kernels",
0034         default=0.001,
0035     )
0036 
0037     args = parser.parse_args()
0038 
0039     logging.basicConfig(
0040         level=logging.INFO,
0041         format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
0042     )
0043 
0044     log.info('Loading CSV database "%s"', args.input)
0045     df = pandas.read_csv(args.input)
0046 
0047     valid_kernels = set()
0048 
0049     commits = []
0050 
0051     log.info("Filtering kernels with a threshold of %f seconds", args.threshold)
0052 
0053     for x in df.iloc:
0054         if x["rec_throughput"] >= args.threshold:
0055             valid_kernels.add(x["kernel"])
0056         if x["commit"] not in commits:
0057             commits.append(x["commit"])
0058 
0059     log.info("Plotting %d kernels over %d commits", len(valid_kernels), len(commits))
0060 
0061     sorted_valid_kernels = sorted(list(valid_kernels))
0062 
0063     px = 1 / matplotlib.pyplot.rcParams["figure.dpi"]
0064 
0065     f, a = matplotlib.pyplot.subplots(1, 1, figsize=(806 * px, 600 * px))
0066 
0067     xrange = list(range(len(commits)))
0068 
0069     for x in sorted_valid_kernels:
0070         x_data = []
0071         y_data = []
0072         y_error = []
0073 
0074         for y in df.iloc:
0075             if y["kernel"] == x:
0076                 x_data.append(commits.index(y["commit"]))
0077                 y_data.append(y["rec_throughput"] * 1000)
0078                 y_error.append(y["rec_throughput_dev"] * 1000)
0079 
0080         a.errorbar(
0081             x_data, y_data, yerr=y_error, label=x, marker="x", capsize=2, elinewidth=1
0082         )
0083 
0084     a.set_xticks(
0085         xrange, [x[:8] for x in commits], rotation="vertical", family="monospace"
0086     )
0087     a.set_xlabel("Commit hash")
0088     a.set_ylabel("Reciprocal throughput [ms]")
0089     a.legend(prop={"family": "monospace"})
0090     a.grid(color="lightgray", linewidth=0.5)
0091     f.tight_layout()
0092 
0093     log.info('Saving plot to "%s"', args.output)
0094 
0095     f.savefig(args.output)
0096 
0097 
0098 if __name__ == "__main__":
0099     main()