Skip to content

Conversation

@lkollar
Copy link
Contributor

@lkollarlkollar commented Dec 22, 2025

* - Default for ``--interval`` / ``-i``
- 100 µs between samples (~10,000 samples/sec)
* - Default for ``--sampling-rate`` / ``-r``
- 10 kHz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the documentation to reflect the actual 1 kHz default

help="sampling interval",
"-r",
"--sampling-rate",
type=_parse_sampling_rate,
Copy link
Member

@pablogsalpablogsalDec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The argument is named sampling_rate but after parsing it stores the interval in microseconds, not the rate in Hz. This is kind of confusing in the rest of the code


match=_RATE_PATTERN.match(rate_str)
ifnotmatch:
raiseargparse.ArgumentTypeError(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Let's add a hint about spaces in the error message since "10 khz" (with space) is rejected but users might try it

returnprocess


_RATE_PATTERN=re.compile(r'^(\d+(?:\.\d+)?)(hz|khz|k)?$', re.IGNORECASE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_RATE_PATTERN=re.compile(r'^(\d+(?:\.\d+)?)(hz|khz|k)?$', re.IGNORECASE)
_RATE_PATTERN=re.compile(r'''
^# Start of string
( # Group 1: The numeric value
\d+# One or more digits (integer part)
(?:\.\d+)? # Optional: decimal point followed by digits
) # Examples: "10", "0.5", "100.25"
( # Group 2: Optional unit suffix
hz# "hz" - hertz
|khz# "khz" - kilohertz
|k# "k" - shorthand for kilohertz
)? # Suffix is optional (bare number = Hz)
$ # End of string
''', re.VERBOSE|re.IGNORECASE)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha you know how much I like to comment these :)

Copy link
Member

@pablogsalpablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once the documentation is updated! 🚀

@pablogsal
Copy link
Member

@lkollar There is a conflict we need to resolve on cli.py

Sampling rate is more intuitive to the number of samples per second taken, rather than the intervals between samples.
@lkollarlkollarforce-pushed the profiling/sample-rate-cli branch from 578e0cc to f392e82CompareDecember 24, 2025 13:21
Copy link
Member

@pablogsalpablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great work 👌

@pablogsalpablogsal enabled auto-merge (squash) December 24, 2025 13:23
@pablogsalpablogsal merged commit d4dc3dd into python:mainDec 24, 2025
50 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@lkollar@pablogsal