Skip to content

Commit

Permalink
Merge pull request #8 from bookingcom/gtarasov/publish_prewarming
Browse files Browse the repository at this point in the history
Add appStartInfo to a public API
  • Loading branch information
pilot34 authored Jan 24, 2024
2 parents 94eed1d + e23a90d commit 4477cfc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions PerformanceSuite/Sources/PerformanceMonitoring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ public enum PerformanceMonitoring {
}
}


/// The information about the recent app start
public static var appStartInfo: AppStartInfo {
return AppInfoHolder.appStartInfo
}

private static func appendTTIObservers(config: Config, vcObservers: inout [ViewControllerObserver]) {
guard let screenTTIReceiver = config.screenTTIReceiver else {
return
Expand Down
14 changes: 14 additions & 0 deletions PerformanceSuite/Tests/PerformanceMonitoringTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ final class PerformanceMonitoringTests: XCTestCase {
let vc2 = UIViewController()
wait(for: [exp2], timeout: 0.5)
_ = vc2

let appStartInfo = PerformanceMonitoring.appStartInfo
XCTAssertFalse(appStartInfo.appStartedWithPrewarming)
}

func testPrewarming() throws {
setenv("ActivePrewarm", "1", 1)
PerformanceMonitoring.onMainStarted()
try PerformanceMonitoring.enable(config: .all(receiver: self))

XCTAssertTrue(PerformanceMonitoring.appStartInfo.appStartedWithPrewarming)

try PerformanceMonitoring.disable()
setenv("ActivePrewarm", "", 1)
}

private var onInitExpectation: XCTestExpectation?
Expand Down

0 comments on commit 4477cfc

Please sign in to comment.