#!/usr/bin/env python3
"""
Displays a hotspot report generated by the Intel VTune profiler.
"""
import argparse
from gcpy.profile.vtune_utils import vtune_compare_a_hotspot
[docs]
def main():
"""
Parses arguments and calls gcpy.profile.vtune_compare_a_hotspot.
This will compare timing information for a given hotspot listed in
two Intel VTune hotspot reports.
Command-line Arguments
----------------------
--ref-file : str
VTune hotspot report for the Ref model.
--ref-label : str
Descriptive label for the Ref model.
--dev-file : str
VTune hotspot report for the Dev model.
--dev-label : str
Descriptive label for the Dev model.
--hotspot, -h : str
Name of the hotspot to look up.
--delimiter, -d : str, optional
Separator between columns.
Default value: "\\t" (tab)
--ref-line-number : int
Line where hotspot occurs in the Ref report.
--dev-line-number : int
Line where hotspot occurs in the Dev report.
"""
# Tell the parser which arguments to look for
parser = argparse.ArgumentParser(
description="Compares a hotspot in two different Intel VTune hotspot reports",
)
parser.add_argument(
"--ref-file",
metavar="REF-FILE",
type=str,
required=True,
help="Intel VTune Hotspot report (in CSV format) for the Ref model",
)
parser.add_argument(
"--ref-label",
metavar="REF-LABEL",
type=str,
required=True,
help="Descriptive label for the Ref model",
)
parser.add_argument(
"--dev-file",
metavar="DEV-FILE",
type=str,
required=True,
help="Intel VTune Hotspot report (in CSV format) for the Dev model"
)
parser.add_argument(
"--dev-label",
metavar="DEV-LABEL",
type=str,
required=True,
help="Descriptive label for the Dev model",
)
parser.add_argument(
"--hotspot-name", "-n",
metavar="HOTSPOT-NAME",
type=str,
required=True,
help="Name of the hotspot to look up",
)
parser.add_argument(
"--delimiter",
metavar="DELIMITER",
type=str,
required=False,
help="Character used to separate columns in each hotspot report",
default="\t",
)
parser.add_argument(
"--ref-line-number",
metavar="REF-LINE-NUMBER",
type=str,
required=False,
help="Line number where the hotspot occurs in the Ref hotspot report",
default="",
)
parser.add_argument(
"--dev-line-number",
metavar="DEV-LINE-NUMBER",
type=str,
required=False,
help="Line number where the hotspot occurs in the Dev hotspot report",
default="",
)
# Parse command-line arguments
args = parser.parse_args()
# Display the hotspot report
vtune_compare_a_hotspot(
args.ref_file,
args.ref_label,
args.dev_file,
args.dev_label,
args.hotspot_name,
delimiter=args.delimiter,
ref_line_number=args.ref_line_number,
dev_line_number=args.dev_line_number,
)
if __name__ == '__main__':
main()