detached 6d0032f

chore(tools): measure bench CPU time from schedstat

commit
6d0032ffa888061d058b322a36154a5d7c810f58
author
brice · · 2026-10-13 16:06 UTC
parent
99ddc5d
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +6 -6
M tools/bench/bench.sh +6 -6
@@ -58,20 +58,20 @@ pids+=("$!")
5858 sleep 8
5959
6060 cs() { cat /proc/"$nwl"/task/*/status | awk '/^voluntary_ctxt/{v+=$2} END{print v}'; }
61-ticks() { awk '{print $14+$15}' /proc/"$nwl"/stat; }
61+# CPU time in ns summed over threads (schedstat is finer than stat's ticks).
62+ticks() { cat /proc/"$nwl"/task/*/schedstat | awk '{v+=$1} END{printf "%d\n", v}'; }
6263 frames() { grep -c '"message":"frame"' "$log" || true; }
6364
6465 t0=$(ticks); f0=$(frames); c0=$(cs)
6566 sleep "$secs"
6667 t1=$(ticks); f1=$(frames); c1=$(cs)
6768
68-hz=$(getconf CLK_TCK)
69-python3 - "$((t1 - t0))" "$((f1 - f0))" "$((c1 - c0))" "$secs" "$hz" "$page" <<'EOF'
69+python3 - "$((t1 - t0))" "$((f1 - f0))" "$((c1 - c0))" "$secs" "$page" <<'EOF'
7070 import sys
71-t, f, c, s, hz, page = int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]), float(sys.argv[4]), int(sys.argv[5]), sys.argv[6]
72-cpu = t / hz / s * 100
71+t, f, c, s, page = int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]), float(sys.argv[4]), sys.argv[5]
72+cpu = t / 1e9 / s * 100
7373 fr = max(f, 1)
74-print(f"{page} cpu%={cpu:.2f} fps={f / s:.1f} ms/frame={t / hz * 1000 / fr:.3f} cs/frame={c / fr:.0f}")
74+print(f"{page} cpu%={cpu:.2f} fps={f / s:.1f} ms/frame={t / 1e6 / fr:.3f} cs/frame={c / fr:.0f}")
7575 EOF
7676
7777 if [ -n "${BENCH_KEEP:-}" ]; then
@@ -58,20 +58,20 @@ pids+=("$!")
58 sleep 858 sleep 8
59 59
60 cs() { cat /proc/"$nwl"/task/*/status | awk '/^voluntary_ctxt/{v+=$2} END{print v}'; }60 cs() { cat /proc/"$nwl"/task/*/status | awk '/^voluntary_ctxt/{v+=$2} END{print v}'; }
61-ticks() { awk '{print $14+$15}' /proc/"$nwl"/stat; }61+# CPU time in ns summed over threads (schedstat is finer than stat's ticks).
62+ticks() { cat /proc/"$nwl"/task/*/schedstat | awk '{v+=$1} END{printf "%d\n", v}'; }
62 frames() { grep -c '"message":"frame"' "$log" || true; }63 frames() { grep -c '"message":"frame"' "$log" || true; }
63 64
64 t0=$(ticks); f0=$(frames); c0=$(cs)65 t0=$(ticks); f0=$(frames); c0=$(cs)
65 sleep "$secs"66 sleep "$secs"
66 t1=$(ticks); f1=$(frames); c1=$(cs)67 t1=$(ticks); f1=$(frames); c1=$(cs)
67 68
68-hz=$(getconf CLK_TCK)69+python3 - "$((t1 - t0))" "$((f1 - f0))" "$((c1 - c0))" "$secs" "$page" <<'EOF'
69-python3 - "$((t1 - t0))" "$((f1 - f0))" "$((c1 - c0))" "$secs" "$hz" "$page" <<'EOF'
70 import sys70 import sys
71-t, f, c, s, hz, page = int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]), float(sys.argv[4]), int(sys.argv[5]), sys.argv[6]71+t, f, c, s, page = int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]), float(sys.argv[4]), sys.argv[5]
72-cpu = t / hz / s * 10072+cpu = t / 1e9 / s * 100
73 fr = max(f, 1)73 fr = max(f, 1)
74-print(f"{page} cpu%={cpu:.2f} fps={f / s:.1f} ms/frame={t / hz * 1000 / fr:.3f} cs/frame={c / fr:.0f}")74+print(f"{page} cpu%={cpu:.2f} fps={f / s:.1f} ms/frame={t / 1e6 / fr:.3f} cs/frame={c / fr:.0f}")
75 EOF75 EOF
76 76
77 if [ -n "${BENCH_KEEP:-}" ]; then77 if [ -n "${BENCH_KEEP:-}" ]; then

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 25

Tags 10

↑↓ moveenter openesc close