Skip to content

Commit 7c6e82d

Browse files
committed
Change sampling_rate to sample_interval_usec
We are now parsing the interval rather than the frequency.
1 parent 9e1bd5c commit 7c6e82d

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

Lib/profiling/sampling/cli.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _build_child_profiler_args(args):
113113
child_args = []
114114

115115
# Sampling options
116-
hz = MICROSECONDS_PER_SECOND // args.sampling_rate
116+
hz = MICROSECONDS_PER_SECOND // args.sample_interval_usec
117117
child_args.extend(["-r", str(hz)])
118118
child_args.extend(["-d", str(args.duration)])
119119

@@ -332,6 +332,7 @@ def _add_sampling_options(parser):
332332
type=_parse_sampling_rate,
333333
default="1khz",
334334
metavar="RATE",
335+
dest="sample_interval_usec",
335336
help="sampling rate (e.g., 10000, 10khz, 10k)",
336337
)
337338
sampling_group.add_argument(
@@ -802,7 +803,9 @@ def _handle_attach(args):
802803
)
803804

804805
# Create the appropriate collector
805-
collector = _create_collector(args.format, args.sampling_rate, skip_idle, args.opcodes)
806+
collector = _create_collector(
807+
args.format, args.sample_interval_usec, skip_idle, args.opcodes
808+
)
806809

807810
with _get_child_monitor_context(args, args.pid):
808811
collector = sample(
@@ -871,7 +874,9 @@ def _handle_run(args):
871874
)
872875

873876
# Create the appropriate collector
874-
collector = _create_collector(args.format, args.sampling_rate, skip_idle, args.opcodes)
877+
collector = _create_collector(
878+
args.format, args.sample_interval_usec, skip_idle, args.opcodes
879+
)
875880

876881
with _get_child_monitor_context(args, process.pid):
877882
try:
@@ -909,7 +914,7 @@ def _handle_live_attach(args, pid):
909914

910915
# Create live collector with default settings
911916
collector = LiveStatsCollector(
912-
args.sampling_rate,
917+
args.sample_interval_usec,
913918
skip_idle=skip_idle,
914919
sort_by="tottime", # Default initial sort
915920
limit=20, # Default limit
@@ -955,7 +960,7 @@ def _handle_live_run(args):
955960

956961
# Create live collector with default settings
957962
collector = LiveStatsCollector(
958-
args.sampling_rate,
963+
args.sample_interval_usec,
959964
skip_idle=skip_idle,
960965
sort_by="tottime", # Default initial sort
961966
limit=20, # Default limit

Lib/test/test_profiling/test_sampling_profiler/test_children.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def test_build_child_profiler_args(self):
384384
from profiling.sampling.cli import _build_child_profiler_args
385385

386386
args = argparse.Namespace(
387-
sampling_rate=200,
387+
sample_interval_usec=200,
388388
duration=15,
389389
all_threads=True,
390390
realtime_stats=False,
@@ -442,7 +442,7 @@ def test_build_child_profiler_args_no_gc(self):
442442
from profiling.sampling.cli import _build_child_profiler_args
443443

444444
args = argparse.Namespace(
445-
sampling_rate=100,
445+
sample_interval_usec=100,
446446
duration=5,
447447
all_threads=False,
448448
realtime_stats=False,
@@ -508,7 +508,7 @@ def test_setup_child_monitor(self):
508508
from profiling.sampling.cli import _setup_child_monitor
509509

510510
args = argparse.Namespace(
511-
sampling_rate=100,
511+
sample_interval_usec=100,
512512
duration=5,
513513
all_threads=False,
514514
realtime_stats=False,

0 commit comments

Comments
 (0)