Skip to content

Commit ae52984

Browse files
tmmampagent
andauthored
test(zero-swift): show the frames behind a flagged fling momentum jump (#98)
Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859 Co-authored-by: Amp <amp@ampcode.com>
1 parent 9de9853 commit ae52984

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎swift/TestHost/App/FrameProbe.swift‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,24 @@ final class FrameProbe {
376376
let sample = w[3].sample
377377
let moved = w[2].dy + w[3].dy
378378
if abs(m - expected) > max(300, 0.15 * abs(expected)) {
379+
// The six frames, each as how far the rows moved on screen, over how
380+
// long, how late it was sampled, and how far the top row moved in the
381+
// content: rows the list moved move there; a scroll view's momentum
382+
// that ran unevenly, or was sampled unevenly, moves only the offset.
383+
let ref = sample.ids.first(where: Self.isRow)
384+
let frames = w.map { e in
385+
let shift = ref.flatMap { id in
386+
e.sample.content[id].flatMap { c in w[0].sample.content[id].map { c - $0 } }
387+
}
388+
return
389+
"\(fmt(e.dy))/\(fmt(e.dt * 1000))ms/lat \(fmt(e.sample.latency * 1000))/content \(shift.map(fmt) ?? "-")"
390+
}
379391
// Once per jump: the next check starts after it.
380392
smooth.removeAll()
381393
flag(
382394
sample,
383-
"speed \(fmt(m)) between \(fmt(p)) and \(fmt(n)) (moved \(fmt(moved)))")
395+
"speed \(fmt(m)) between \(fmt(p)) and \(fmt(n)) (moved \(fmt(moved)); frames \(frames.joined(separator: ", ")))"
396+
)
384397
}
385398
}
386399

0 commit comments

Comments
 (0)