Skip to content

More measurements

Besides the classic marks, the result carries the whole run (speed and distance over time), so you can read any mark after the run.

let r = run.analyze(stopDistance: 850)! // read past the quarter mile
r.zeroTo60mph // 0–60 mph
r.thousandFeet // 1000 ft
r.halfMile // half mile
r.time(fromKmh: 100, toKmh: 200) // speed range
r.time(toKmh: 150) // 0–150 km/h
r.elapsed(toDistance: 100) // 100 meters, with rollout
r.speedKmh(atDistance: 300) // speed at 300 m
r.launchG; r.peakG // launch and peak g

They all return null if the run didn’t reach that mark.

Mark Distance or speed
60 ft 18.288 m
1/8 mile 201.168 m
1000 ft 304.8 m
1/4 mile 402.336 m
1/2 mile 804.672 m
0–60 mph 26.82 m/s

To time a range with the car already moving, arm the session in another mode. It starts recording right away and finishes by itself once the range is covered.

session.arm(mode: .rolling(fromKmh: 60, toKmh: 130)) // passing
session.arm(mode: .braking(fromKmh: 100)) // braking
for await event in session.events() {
if case .intervalFinished(let interval) = event {
print("\(interval.time) s over \(interval.distance) m, \(interval.peakG) g")
}
}
IntervalResult field What it is
kind rolling or braking.
fromKmh, toKmh The requested range.
time Seconds it took.
distance Meters covered in the range.
peakG Peak g (acceleration or braking).
startTime When it started, on the samples’ clock.

If the car doesn’t cover the range (say it never reaches 130), the session fails with noInterval. With a recording you can also compute the range later: run.rolling(fromKmh:toKmh:) and run.braking(fromKmh:).