Skip to content

Commit 0440856

Browse files
committed
Fix small issues
1 parent a8f1bdd commit 0440856

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

Lib/profile/sample.py

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ def main():
534534
sampling_group.add_argument(
535535
"--realtime-stats",
536536
action="store_true",
537+
default=False,
537538
help="Print real-time sampling statistics (Hz, mean, min, max, stdev) during profiling",
538539
)
539540

@@ -628,27 +629,20 @@ def main():
628629
if args.format == "collapsed":
629630
_validate_collapsed_format_args(args, parser)
630631

631-
# Set sort value - use the specified sort or None if not specified
632-
# The default sort=2 is handled by the sample function itself
633-
sort_value = args.sort
634-
635-
# Build the sample function call arguments
636-
sample_kwargs = {
637-
"sample_interval_usec": args.interval,
638-
"duration_sec": args.duration,
639-
"filename": args.outfile,
640-
"all_threads": args.all_threads,
641-
"limit": args.limit,
642-
"sort": sort_value,
643-
"show_summary": not args.no_summary,
644-
"output_format": args.format,
645-
}
646-
647-
# Only add realtime_stats if it's explicitly set to True
648-
if args.realtime_stats:
649-
sample_kwargs["realtime_stats"] = args.realtime_stats
650-
651-
sample(args.pid, **sample_kwargs)
632+
sort_value = args.sort if args.sort is not None else 2
633+
634+
sample(
635+
args.pid,
636+
sample_interval_usec=args.interval,
637+
duration_sec=args.duration,
638+
filename=args.outfile,
639+
all_threads=args.all_threads,
640+
limit=args.limit,
641+
sort=sort_value,
642+
show_summary=not args.no_summary,
643+
output_format=args.format,
644+
realtime_stats=args.realtime_stats,
645+
)
652646

653647

654648
if __name__ == "__main__":

Lib/test/test_sample_profiler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1692,9 +1692,10 @@ def test_argument_parsing_basic(self):
16921692
filename=None,
16931693
all_threads=False,
16941694
limit=15,
1695-
sort=None,
1695+
sort=2,
16961696
show_summary=True,
16971697
output_format="pstats",
1698+
realtime_stats=False,
16981699
)
16991700

17001701
def test_sort_options(self):

0 commit comments

Comments
 (0)