Skip to content

Check for environment XCTEST_MEASURE_MAX_STDDEV for maxRelativeStandardDeviation #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marcprux
Copy link

@marcprux marcprux commented Jan 6, 2025

The XCTest.measure currently uses 10.0 as the hardwired maxRelativeStandardDeviation, which can lead to test failures where a test is expected to have a high standard deviation:

PerformanceTests.swift:90: Test Case 'PerformanceTests.testUsingLoadWithUTF16' measured [Time, seconds] average: 0.884, relative standard deviation: 47.026%, values: [1.063468, 1.418311, 1.400721, 1.412482, 0.927719, 0.639287, 0.497485, 0.438305, 0.601177, 0.436784], performanceMetricID:org.swift.XCTPerformanceMetric_WallClockTime, maxPercentRelativeStandardDeviation: 10.000%, maxStandardDeviation: 0.100
PerformanceTests.swift:90: error: PerformanceTests.testUsingLoadWithUTF16 : failed: The relative standard deviation of the measurements is 47.026% which is higher than the max allowed of 10.000%.

This PR adds a check for the environment variable XCTEST_MEASURE_MAX_STDDEV, which it will use as the default maximum if it is set. Otherwise, it will fall back to 10%.

@marcprux
Copy link
Author

This can be worked around with a technique like jpsim/Yams@67c6444

marcprux added a commit to marcprux/SwiftCBOR that referenced this pull request Mar 31, 2025
hamchapman pushed a commit to valpackett/SwiftCBOR that referenced this pull request Mar 31, 2025
* Android fix and CI
* Add spcial-case measure function for Android to work around large standard deviation on emulator (swiftlang/swift-corelibs-xctest#506)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant