SearchAndReplace = Callable[[str], str]
+
# A typed wrapper for parsed args.
class Args(Namespace):
# None of these fields are modified after arg parsing finishes.
p.print_usage(file=sys.stderr)
die("argument --diff: requires exactly two Cachegrind output files")
- return args0
+ return args0 # type: ignore [return-value]
# Args are stored in a global for easy access.
# type is very hot and just using a type alias is much faster.
Cc = list[int]
+
# Add the counts in `a_cc` to `b_cc`.
def add_cc_to_cc(a_cc: Cc, b_cc: Cc) -> None:
for i, a_count in enumerate(a_cc):
# `--mod-funcname`.
# - Mname/mname: modified name, used for what could be an Mfl or an Mfn.
+
# A deep cost centre with a dict for the inner mnames and CCs.
class Dcc:
outer_cc: Cc
print()
# Print LCCs.
- threshold_mnames = set([])
+ threshold_mnames: set[str] = set([])
cumul_cc = events.mk_empty_cc()
for mname, lcc in list_mname_lcc:
add_cc_to_cc(lcc.outer_cc, cumul_cc)
# mtimes as if they are all as early as the earliest one.
# Therefore, we warn only if the earliest source file is
# more recent than the cgout file.
- min_ofl_st_mtime_ns = min(
- [os.stat(ofl).st_mtime_ns for ofl in ofls]
- )
+ min_ofl_st_mtime_ns = min(os.stat(ofl).st_mtime_ns for ofl in ofls)
for cgout_filename in args.cgout_filename:
if min_ofl_st_mtime_ns > os.stat(cgout_filename).st_mtime_ns:
print()
total_cc = events.mk_empty_cc()
- for (cc, label) in zip(annotated_ccs.ccs(), AnnotatedCcs.labels):
+ for cc, label in zip(annotated_ccs.ccs(), AnnotatedCcs.labels):
printer.print_cc(cc, None, label)
add_cc_to_cc(cc, total_cc)
help="file produced by Cachegrind",
)
- return p.parse_args(namespace=Args())
+ return p.parse_args(namespace=Args()) # type: ignore [return-value]
# Args are stored in a global for easy access.
args = Args.parse()
+
# A single instance of this class is constructed, from `args` and the `events:`
# line in the cgout file.
class Events:
# type is very hot and just using a type alias is much faster.
Cc = list[int]
+
# Add the counts in `a_cc` to `b_cc`.
def add_cc_to_cc(a_cc: Cc, b_cc: Cc) -> None:
for i, a_count in enumerate(a_cc):
help="file produced by Cachegrind",
)
- return p.parse_args(namespace=Args())
+ return p.parse_args(namespace=Args()) # type: ignore [return-value]
# Args are stored in a global for easy access.
args = Args.parse()
+
# A single instance of this class is constructed, from `args` and the `events:`
# line in the cgout file.
class Events: