Repository: airbnb/lottie-ios
File: Tests/PerformanceTests.swift (Swift)

Code before:
// Created by Cal Stephens on 2/14/22.
// Copyright © 2022 Airbnb Inc. All rights reserved.

import Foundation
import XCTest

@testable import Lottie

// MARK: - PerformanceTests

final class PerformanceTests: XCTestCase {

  // MARK: Internal

  func testAnimationViewSetup_simpleAnimation() {
    // Compare the performance of displaying this simple animation in the two animation engines
    let ratio = compareEngineSetupPerformance(for: simpleAnimation, iterations: 2000)

    // This is basically a snapshot test for the performance of the Core Animation engine
    // compared to the Main Thread engine. Currently, the Core Animation engine is
    // about 1.6x slower than the Main Thread engine in this example.
    XCTAssertEqual(ratio, 1.6, accuracy: 0.2)
  }

  func testAnimationViewSetup_complexAnimation() {
    let ratio = compareEngineSetupPerformance(for: complexAnimation, iterations: 500)
    XCTAssertEqual(ratio, 1.75, accuracy: 0.3)
  }

  func testAnimationViewScrubbing_simpleAnimation() {
    let ratio = compareEngineScrubbingPerformance(for: simpleAnimation, iterations: 1000)
    XCTAssertEqual(ratio, 0.05, accuracy: 0.02)
  }

  func testAnimationViewScrubbing_complexAnimation() {
    let ratio = compareEngineScrubbingPerformance(for: complexAnimation, iterations: 1000)
    XCTAssertEqual(ratio, 0.002, accuracy: 0.001)
  }

  // MARK: Private

  private let simpleAnimation = Animation.named(
    "loading_dots_1",
    bundle: .module,
    subdirectory: "Samples/LottieFiles")!

  private let complexAnimation = Animation.named(

Review comment (suggestion):
bumping this to give more leeway in CI

```suggestion
    XCTAssertEqual(ratio, 1.6, accuracy: 0.3)
```

Code after:
// Created by Cal Stephens on 2/14/22.
// Copyright © 2022 Airbnb Inc. All rights reserved.

import Foundation
import XCTest

@testable import Lottie

// MARK: - PerformanceTests

final class PerformanceTests: XCTestCase {

  // MARK: Internal

  func testAnimationViewSetup_simpleAnimation() {
    // Compare the performance of displaying this simple animation in the two animation engines
    let ratio = compareEngineSetupPerformance(for: simpleAnimation, iterations: 2000)

    // This is basically a snapshot test for the performance of the Core Animation engine
    // compared to the Main Thread engine. Currently, the Core Animation engine is
    // about the same speed as the Main Thread engine in this example.
    XCTAssertEqual(ratio, 1.0, accuracy: 0.15)
  }

  func testAnimationViewSetup_complexAnimation() {
    let ratio = compareEngineSetupPerformance(for: complexAnimation, iterations: 500)

    // The Core Animation engine is currently about 1.6x slower than the
    // Main Thread engine in this example.
    XCTAssertEqual(ratio, 1.6, accuracy: 0.3)
  }

  func testAnimationViewScrubbing_simpleAnimation() {
    let ratio = compareEngineScrubbingPerformance(for: simpleAnimation, iterations: 2000)
    XCTAssertEqual(ratio, 0.002, accuracy: 0.001)
  }

  func testAnimationViewScrubbing_complexAnimation() {
    let ratio = compareEngineScrubbingPerformance(for: complexAnimation, iterations: 2000)
    XCTAssertEqual(ratio, 0.0005, accuracy: 0.00035)
  }

  override func setUp() {
    TestHelpers.performanceTestsAreRunning = true
  }

  override func tearDown() {