@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 36 lines 1.04 KB
Raw
1 import { assert, describe, it } from "@effect/vitest";
2
3 import * as EventLoopMonitor from "./EventLoopMonitor.ts";
4
5 const ms = (value: number) => value * 1e6;
6
7 // Node reports a stall of S as a gap of up to S + 1 s, the histogram resolution.
8 const stalled: EventLoopMonitor.EventLoopReadings = {
9 delayMaxNs: ms(5_950),
10 activeMs: 6_200,
11 utilization: 0.176,
12 usage: {
13 userCPUTime: 310_400,
14 systemCPUTime: 95_600,
15 majorPageFault: 8_412,
16 minorPageFault: 20_031,
17 involuntaryContextSwitches: 57,
18 },
19 rssBytes: 1536 * 1024 * 1024,
20 heapUsedBytes: 512 * 1024 * 1024,
21 elapsedMs: 30_000,
22 loadAverage: 219.43,
23 cpuCount: 18,
24 };
25
26 describe("EventLoopMonitor", () => {
27 it("ignores delay the loop spent idle, such as a system sleep", () => {
28 const asleep: EventLoopMonitor.EventLoopReadings = {
29 ...stalled,
30 delayMaxNs: ms(600_000),
31 activeMs: 900,
32 };
33 assert.isUndefined(EventLoopMonitor.stallMs(asleep));
34 assert.strictEqual(EventLoopMonitor.stallMs({ ...asleep, activeMs: 600_000 }), 599_000);
35 });
36 });