@@ -2661,10 +2661,10 @@ enum DistributionCaptureConfiguration {
|
||
| 2661 | 2661 |
if veryHighVolumeTypeIdentifiers.contains(typeIdentifier) {
|
| 2662 | 2662 |
return DistributionCaptureStrategy( |
| 2663 | 2663 |
queryPageLimit: 2_000, |
| 2664 |
- initialWriteChunkSize: 500, |
|
| 2665 |
- minimumWriteChunkSize: 100, |
|
| 2666 |
- slowBatchThresholdSeconds: 1.25, |
|
| 2667 |
- severeBatchThresholdSeconds: 4 |
|
| 2664 |
+ initialWriteChunkSize: 2_000, |
|
| 2665 |
+ minimumWriteChunkSize: 500, |
|
| 2666 |
+ slowBatchThresholdSeconds: 2.5, |
|
| 2667 |
+ severeBatchThresholdSeconds: 6 |
|
| 2668 | 2668 |
) |
| 2669 | 2669 |
} |
| 2670 | 2670 |
|
@@ -0,0 +1,32 @@ |
||
| 1 |
+import HealthKit |
|
| 2 |
+import XCTest |
|
| 3 |
+@testable import HealthProbe |
|
| 4 |
+ |
|
| 5 |
+final class DistributionCaptureConfigurationTests: XCTestCase {
|
|
| 6 |
+ func testHeartRateInitialImportUsesLargerWriteChunks() {
|
|
| 7 |
+ let strategy = DistributionCaptureConfiguration.initialImportStrategy( |
|
| 8 |
+ for: HKQuantityTypeIdentifier.heartRate.rawValue |
|
| 9 |
+ ) |
|
| 10 |
+ |
|
| 11 |
+ XCTAssertEqual(strategy.queryPageLimit, 2_000) |
|
| 12 |
+ XCTAssertEqual(strategy.initialWriteChunkSize, 2_000) |
|
| 13 |
+ XCTAssertEqual(strategy.minimumWriteChunkSize, 500) |
|
| 14 |
+ XCTAssertEqual(strategy.slowBatchThresholdSeconds, 2.5) |
|
| 15 |
+ XCTAssertEqual(strategy.severeBatchThresholdSeconds, 6) |
|
| 16 |
+ } |
|
| 17 |
+ |
|
| 18 |
+ func testHeartRateWriteChunkCanBackOffOnSlowDevices() {
|
|
| 19 |
+ let strategy = DistributionCaptureConfiguration.initialImportStrategy( |
|
| 20 |
+ for: HKQuantityTypeIdentifier.heartRate.rawValue |
|
| 21 |
+ ) |
|
| 22 |
+ var state = strategy.makePersistenceState() |
|
| 23 |
+ |
|
| 24 |
+ state.registerBatchDuration(strategy.severeBatchThresholdSeconds) |
|
| 25 |
+ |
|
| 26 |
+ XCTAssertEqual(state.currentWriteChunkSize, 1_000) |
|
| 27 |
+ |
|
| 28 |
+ state.registerBatchDuration(strategy.severeBatchThresholdSeconds) |
|
| 29 |
+ |
|
| 30 |
+ XCTAssertEqual(state.currentWriteChunkSize, 500) |
|
| 31 |
+ } |
|
| 32 |
+} |
|