Skip to content

armgit / cra

Public Imported from GitHub
0

The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.

Perf harness: the observer-cost test counts run-loop turns, not seconds

Victor9e2d728e4efd
diff --git a/Tests/PerfTests.swift b/Tests/PerfTests.swift
index 7c02c3d..cb9024b 100644
--- a/Tests/PerfTests.swift
+++ b/Tests/PerfTests.swift
@@ -330,9 +330,13 @@ enum PerfTests {
// One extra turn, so callbacks that end a pass (and report the stall) fall on the old
// one-in-256 timing too.
RunLoop.main.run(mode: .default, before: Date())
- let timer = Timer(timeInterval: 0.001, repeats: true) { _ in }
+ // A turn every 5 ms, longer than the 2 ms wait, so the loop sleeps between turns: each
+ // turn is a pass of two callbacks however slow the build (sanitizers) or the Mac.
+ var turns = 0
+ let timer = Timer(timeInterval: 0.005, repeats: true) { _ in turns += 1 }
RunLoop.main.add(timer, forMode: .common)
- spin(1.0)
+ let limit = Date().addingTimeInterval(60)
+ while turns < 400, Date() < limit { spin(0.1) }
timer.invalidate()
observer.stop()
let d = observer.drain()