perf(editor): native Windows preview and UI-first timeline navigation (#11)
Gitea CI / Check code and tests (push) Successful in 8m7s
Gitea CI / Build Windows x64 app (push) Successful in 5m48s
Gitea CI / Build Android APK (push) Successful in 5m59s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m17s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m22s
Gitea CI / Gitea CI passed (push) Successful in 2s

This commit was merged in pull request #11.
This commit is contained in:
lingjhf committed 2026-10-07 10:05:14 +00:00
1 parent 0ecf920669
commit b4cb12cbe3
36 files changed
+3292 -148

No files matched your search

@@ -0,0 +1,96 @@
import 'config.dart';
/// A deterministic input sequence; independent of Flutter, decoding and sampling.
class ViewportBenchWorkload {
const ViewportBenchWorkload({
required this.scenario,
required this.hz,
required this.count,
required this.firstFrame,
required this.lastFrame,
required this.steps,
required this.paired,
required this.localSpanFrames,
required this.timelineEndFrame,
});
final int scenario, hz, count, firstFrame, lastFrame, steps, localSpanFrames;
final bool paired;
final double timelineEndFrame;
bool get local => paired && scenario == 1;
double get durationMs => 1000 * count / hz;
int get warmFrame => idealFrame(0) - 1;
int get cameraBaseFrame => firstFrame - 17;
int idealFrame(int i) {
if (local) {
final phase = i % (2 * localSpanFrames);
return firstFrame +
(phase <= localSpanFrames ? phase : 2 * localSpanFrames - phase);
}
if (paired) {
final half = count ~/ 2;
final phase = i % count;
final index = phase < half ? phase : count - 1 - phase;
return (timelineEndFrame * (.05 + .9 * index / (half - 1))).round();
}
final period = 2 * (steps - 1);
final phase = i % period;
final index = switch (scenario) {
0 => i,
1 => steps - 1 - i,
_ => phase < steps ? phase : period - phase,
};
return (firstFrame * (steps - 1) +
(lastFrame - firstFrame) * index +
(steps - 1) ~/ 2) ~/
(steps - 1);
}
static List<ViewportBenchWorkload> forTimeline(
ViewportBenchConfig config,
double endFrame,
) {
if (!endFrame.isFinite ||
endFrame < 2 * config.edgeMarginFrames + 2 ||
(config.expectedFrames != null &&
(endFrame - config.expectedFrames!).abs() > 2)) {
throw StateError('Unexpected normal timeline length: $endFrame');
}
final localStart = config.localStartFrame ?? (endFrame * .28).round();
if (config.paired &&
(localStart < 18 || localStart + config.localSpanFrames >= endFrame)) {
throw StateError('Local benchmark range falls outside the timeline');
}
final steps = config.inputCount ~/ 3;
return List.generate(config.paired ? 2 : 5, (scenario) {
final hz = config.paired
? config.inputHz
: config.inputHz * [1, 2, 1, 2, 4][scenario];
final count = config.paired
? config.inputCount
: [
steps,
steps,
config.inputCount,
config.inputCount * 2,
config.inputCount * 4,
][scenario];
return ViewportBenchWorkload(
scenario: scenario,
hz: hz,
count: count,
firstFrame: config.paired
? (scenario == 0 ? (endFrame * .05).round() : localStart)
: config.edgeMarginFrames,
lastFrame: config.paired
? (endFrame * .95).round()
: endFrame.round() - config.edgeMarginFrames - 1,
steps: steps,
paired: config.paired,
localSpanFrames: config.localSpanFrames,
timelineEndFrame: endFrame,
);
});
}
}