Fix calculateCPUPercent docstring parameter names and units#1903
Open
anxkhn wants to merge 1 commit into
Open
Conversation
The docstring listed the parameters as cpuUsageUsec1, cpuUsageUsec2, and timeDeltaUsec, each described as microseconds, but the function signature takes cpuUsage1, cpuUsage2, and timeInterval as Duration values. Rename the documented parameters to match the signature and describe them as durations so DocC and Xcode no longer warn about mismatched parameter names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So all three documented names were stale and the "microseconds" unit contradicted
the
Durationparameter types (the body dividesDurationbyDurationdirectly). DocC / Xcode flag
- Parameters:entries whose names do not match thesignature, so this produced parameter-name warnings and misleading docs.
This updates the docstring to the real parameter names and describes them as the
durations they are:
cpuUsage1/cpuUsage2: cumulative CPU time from each sample (the call sitebuilds these with
.microseconds(cpuUsageUsec)from the cumulative usagefields).
timeInterval: the elapsed wall-clock time between the two samples (the callsite passes
.seconds(2), the sampling interval).Comment-only change; no behavior change.
Testing
Doc-only change, so no unit test applies. Verified with the repo's tooling:
swift format lint --strict --configuration .swift-format-nolinton the file:exit 0.
swift format --configuration .swift-formaton the file: no diff (alreadycanonical).
swift build --target ContainerCommands: builds cleanly; the file recompiles.