GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Wall-clock render timing trend per commit (#22) · Gherkin/HTMLPCBViewer@9eabca4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • ci.yml
  • tests/browser
    • perf.spec.js
  • tools
    • perf_trend.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/ci.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/ci.yml
+68Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ jobs:
117117
run: python generate.py tests/fixtures/netdaq-small.json -o tests/browser/board.html
118118

119119
- run: npx playwright test
120+
env:
121+
PERF_WALLCLOCK_OUT: perf/wall-clock.json
120122

121123
- uses: actions/upload-artifact@v7
122124
if: always()
@@ -125,6 +127,72 @@ jobs:
125127
path: playwright-report/
126128
retention-days: 7
127129

130+
- uses: actions/upload-artifact@v7
131+
with:
132+
name: wall-clock
133+
path: perf/wall-clock.json
134+
if-no-files-found: error
135+
retention-days: 7
136+
137+
# Wall-clock render numbers per commit (#18). History lives on the
138+
# perf-history branch, one file per commit on main. Fails only on a 10x
139+
# change, since hosted runners are noisy. Main pushes record even when the
140+
# check fails, so a deliberate change becomes the new median after a few
141+
# commits. publish does not wait for it, so a failure here never blocks a
142+
# release.
143+
perf-trend:
144+
name: Perf trend
145+
needs: browser
146+
runs-on: ubuntu-latest
147+
permissions:
148+
contents: write
149+
steps:
150+
- uses: actions/checkout@v7
151+
152+
- uses: actions/setup-node@v7
153+
with:
154+
node-version: '22'
155+
156+
- uses: actions/download-artifact@v8
157+
with:
158+
name: wall-clock
159+
path: perf/
160+
161+
- name: Check out history
162+
run: |
163+
if git ls-remote --exit-code --heads origin perf-history; then
164+
git fetch --depth=50 origin perf-history:perf-history
165+
git worktree add history perf-history
166+
else
167+
git worktree add --orphan -b perf-history history
168+
fi
169+
170+
- name: Compare with history
171+
id: check
172+
run: node tools/perf_trend.js check perf/wall-clock.json history/runs
173+
174+
- name: Record on main
175+
if: >-
176+
!cancelled() && github.event_name == 'push' && github.ref == 'refs/heads/main' &&
177+
(steps.check.outcome == 'success' || steps.check.outcome == 'failure')
178+
run: |
179+
node tools/perf_trend.js record perf/wall-clock.json history/runs \
180+
"$GITHUB_SHA" "$(git log -1 --format=%cI)"
181+
git -C history config user.name 'github-actions[bot]'
182+
git -C history config user.email '41898282+github-actions[bot]@users.noreply.github.com'
183+
git -C history add runs
184+
# A re-run of the same commit replaces its file, possibly unchanged.
185+
git -C history diff --cached --quiet && exit 0
186+
git -C history commit -q -m "perf: ${GITHUB_SHA::12}"
187+
# Each commit adds its own file, so a rebase over a concurrent run
188+
# only conflicts when both recorded the same commit. Then this run's
189+
# file wins, as on a re-run.
190+
for i in 1 2 3; do
191+
git -C history push origin perf-history && exit 0
192+
git -C history pull -q --rebase -X theirs origin perf-history
193+
done
194+
exit 1
195+
128196
# main pushes publish :latest, v* tags publish the version. Both get :sha-<short>.
129197
publish:
130198
name: Publish image
Collapse file

‎tests/browser/perf.spec.js‎

Copy file name to clipboardExpand all lines: tests/browser/perf.spec.js
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
// and commit the new baseline with the change that caused it.
1212
//
1313
// Wall-clock numbers (render p50/p90/p99, droppedFrames, load timings) are
14-
// attached to the test result for reading, and never asserted. GitHub-hosted
15-
// runners are too noisy for them.
14+
// attached to the test result for reading, and never asserted here.
15+
// GitHub-hosted runners are too noisy for them. With PERF_WALLCLOCK_OUT set
16+
// they are also written to that path, and CI tracks them per commit with
17+
// tools/perf_trend.js (#18).
1618
//
1719
// The script waits for the renderer to go idle after every input step. Render
1820
// requests that arrive while one is in flight are merged, so without the wait
@@ -25,6 +27,7 @@ const path = require('path');
2527
const PAGE = 'file://' + path.join(__dirname, 'board.html');
2628
const BASELINE = path.join(__dirname, '..', 'perf', 'baseline.json');
2729
const UPDATE = !!process.env.PERF_UPDATE_BASELINE;
30+
const WALLCLOCK_OUT = process.env.PERF_WALLCLOCK_OUT;
2831

2932
// Draw call culling depends on the canvas size, so pin it rather than
3033
// inheriting whatever the device preset says.
@@ -138,6 +141,10 @@ test('interaction counters match the baseline', async ({ page }, testInfo) => {
138141
body: JSON.stringify(wallClock, null, 2),
139142
contentType: 'application/json',
140143
});
144+
if (WALLCLOCK_OUT) {
145+
fs.mkdirSync(path.dirname(WALLCLOCK_OUT), { recursive: true });
146+
fs.writeFileSync(WALLCLOCK_OUT, JSON.stringify(wallClock, null, 2) + '\n');
147+
}
141148

142149
if (UPDATE) {
143150
fs.mkdirSync(path.dirname(BASELINE), { recursive: true });
Collapse file

‎tools/perf_trend.js‎

Copy file name to clipboard
+129Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
// Per-commit wall-clock trend for the perf spec (#18).
2+
//
3+
// node tools/perf_trend.js check <wall-clock.json> <history-dir>
4+
// node tools/perf_trend.js record <wall-clock.json> <history-dir> <sha> <commit-date>
5+
//
6+
// <wall-clock.json> is what tests/browser/perf.spec.js writes when
7+
// PERF_WALLCLOCK_OUT is set. <history-dir> holds one JSON file per commit on
8+
// main. CI keeps it on the perf-history branch.
9+
//
10+
// check compares render p50/p90/p99 and droppedFrames, per canvas side,
11+
// against the median of the last HISTORY_WINDOW entries. It fails only when a
12+
// value moves by FACTOR or more in either direction. The numbers come from a
13+
// GitHub-hosted runner, so smaller changes are noise. Values are raised to a
14+
// floor before comparing, so 0.5ms against 2ms does not count as 4x. With no
15+
// history yet, check passes.
16+
//
17+
// record writes one file named <commit-date>-<sha>, so the files sort in
18+
// commit order and two runs never touch the same file.
19+
20+
const fs = require("fs");
21+
const path = require("path");
22+
23+
const FACTOR = 10;
24+
const HISTORY_WINDOW = 10;
25+
// Render times are in ms. droppedFrames is a count of renders over 100ms.
26+
const FLOOR = { p50: 5, p90: 5, p99: 5, droppedFrames: 1 };
27+
28+
function usage() {
29+
console.log("usage: node tools/perf_trend.js check <wall-clock.json> <history-dir>");
30+
console.log(" node tools/perf_trend.js record <wall-clock.json> <history-dir> <sha> <commit-date>");
31+
process.exit(2);
32+
}
33+
34+
function readJson(file) {
35+
return JSON.parse(fs.readFileSync(file, "utf8"));
36+
}
37+
38+
// Flatten one wall-clock result to { "F.p50": 5.7, "F.droppedFrames": 0, ... }.
39+
// Sides that did not render are left out.
40+
function metrics(wallClock) {
41+
const out = {};
42+
const stats = wallClock.renderStats || {};
43+
for (const side of Object.keys(stats)) {
44+
const s = stats[side];
45+
if (!s) continue;
46+
out[side + ".p50"] = s.total.p50;
47+
out[side + ".p90"] = s.total.p90;
48+
out[side + ".p99"] = s.total.p99;
49+
out[side + ".droppedFrames"] = s.droppedFrames;
50+
}
51+
return out;
52+
}
53+
54+
function median(values) {
55+
const v = values.slice().sort((a, b) => a - b);
56+
const mid = Math.floor(v.length / 2);
57+
return v.length % 2 ? v[mid] : (v[mid - 1] + v[mid]) / 2;
58+
}
59+
60+
function loadHistory(dir) {
61+
if (!fs.existsSync(dir)) return [];
62+
return fs.readdirSync(dir)
63+
.filter((f) => f.endsWith(".json"))
64+
.sort()
65+
.map((f) => readJson(path.join(dir, f)));
66+
}
67+
68+
function check(wallClockFile, historyDir) {
69+
const current = metrics(readJson(wallClockFile));
70+
const history = loadHistory(historyDir).slice(-HISTORY_WINDOW);
71+
if (history.length === 0) {
72+
console.log("no perf history yet, nothing to compare against");
73+
return 0;
74+
}
75+
const past = history.map((h) => metrics(h.wallClock));
76+
console.log("comparing against the median of the last " + history.length + " commits on main");
77+
console.log("fails on a change of " + FACTOR + "x or more\n");
78+
79+
let failed = 0;
80+
for (const key of Object.keys(current)) {
81+
const values = past.map((m) => m[key]).filter((v) => typeof v === "number");
82+
if (values.length === 0) continue;
83+
const ref = median(values);
84+
const floor = FLOOR[key.split(".")[1]];
85+
const ratio = Math.max(current[key], floor) / Math.max(ref, floor);
86+
const bad = ratio >= FACTOR || ratio <= 1 / FACTOR;
87+
if (bad) failed++;
88+
console.log(
89+
(bad ? "FAIL " : "ok ") + key.padEnd(18) +
90+
" now " + String(round(current[key])).padStart(8) +
91+
" median " + String(round(ref)).padStart(8) +
92+
" x" + round(ratio)
93+
);
94+
}
95+
if (failed) {
96+
console.log("\n" + failed + " wall-clock metric(s) changed by " + FACTOR + "x or more");
97+
return 1;
98+
}
99+
return 0;
100+
}
101+
102+
function round(x) {
103+
return Math.round(x * 100) / 100;
104+
}
105+
106+
function record(wallClockFile, historyDir, sha, commitDate) {
107+
const date = new Date(commitDate);
108+
if (isNaN(date)) {
109+
console.log("bad commit date: " + commitDate);
110+
return 2;
111+
}
112+
// 2026-10-04T12:34:56.000Z -> 20261004T123456Z
113+
const stamp = date.toISOString().replace(/[-:]/g, "").replace(/\.\d+/, "");
114+
const file = path.join(historyDir, stamp + "-" + sha.slice(0, 12) + ".json");
115+
const entry = { sha: sha, date: date.toISOString(), wallClock: readJson(wallClockFile) };
116+
fs.mkdirSync(historyDir, { recursive: true });
117+
fs.writeFileSync(file, JSON.stringify(entry, null, 2) + "\n");
118+
console.log("wrote " + file);
119+
return 0;
120+
}
121+
122+
const [cmd, wallClockFile, historyDir, sha, commitDate] = process.argv.slice(2);
123+
if (cmd === "check" && wallClockFile && historyDir) {
124+
process.exit(check(wallClockFile, historyDir));
125+
} else if (cmd === "record" && wallClockFile && historyDir && sha && commitDate) {
126+
process.exit(record(wallClockFile, historyDir, sha, commitDate));
127+
} else {
128+
usage();
129+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.