Files
komorebi/nix/linux/dev/wsl2-probe-loop.sh
T
LGUG2Z f01853ceca refactor(repo): move the KDE and macOS nix files under nix/ (pure move)
komorebi-for-kde/nix/ -> nix/linux/
komorebi-for-mac/nix/ -> nix/macos/

The nix expressions of the platforms (modules, option files, VM test suites, kwin effects,
the darwin module) sit next to the existing nix/workspace-src.nix. Renames only (252
files); the flakes that import them are replaced by one root flake later in this stack, so
nix does not evaluate at this revision.
2026-11-05 15:03:27 -08:00

23 lines
772 B
Bash

# A CPU loop that scripts/wsl2-probe.sh times in three places: on the host, in a guest under
# KVM and in a guest under TCG. busybox's ash runs it, so the same interpreter runs the same
# instructions everywhere and only the way the CPU is provided differs.
#
# `probe_loop N` counts to N and prints the milliseconds it took, read from /proc/uptime, whose
# resolution is 10 ms: a loop shorter than about a second says little.
# the uptime in centiseconds; the 1 in front of the fraction keeps ash from reading 08 as octal
probe_centis() {
read -r up _ </proc/uptime
echo $((${up%.*} * 100 + 1${up#*.} - 100))
}
probe_loop() {
start=$(probe_centis)
i=0
while [ "$i" -lt "$1" ]; do
i=$((i + 1))
done
end=$(probe_centis)
echo $(((end - start) * 10))
}