About: how pages are checked

tests/sims/redis.test.ts

The automated tests for the /simulators/redis-operations simulator. They run the model on its own, outside the browser, and compare it with a reference that doesn't depend on the model being right. They run on every change to the simulator's code.

  1. The Redis pipelining docs example: a 250 ms round trip caps one client at about 4 requests a second.
  2. Throughput stays within the round-trip and server-time bounds for every client count and depth.
// /simulators/redis-operations: pipelining.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { simulate, bounds, type Params } from '../../src/lib/sims/redispipe.ts';

const base: Params = { clients: 1, depth: 1, rtt: 250000, cmd: 1, syscall: 9, duration: 10000, slowEvery: 0, slowCost: 0 };

test('the Redis pipelining docs example: a 250 ms round trip caps one client at about 4 requests a second', () => {
	const r = simulate(base);
	assert.ok(Math.abs(r.throughput - 4) < 0.15, `${r.throughput} req/s`);
});

test('throughput stays within the round-trip and server-time bounds for every client count and depth', () => {
	for (const depth of [1, 4, 16, 64]) for (const clients of [1, 10, 50, 200]) {
		const p = { ...base, rtt: 200, clients, depth, duration: 1000 };
		const s = simulate(p), b = bounds(p);
		assert.ok(s.throughput <= b.limit * 1.02 && s.throughput >= b.limit * 0.85, `depth ${depth}, ${clients} clients: ${s.throughput} vs bound ${b.limit}`);
	}
});

Shared helpers: tests/sims/check.ts. The model under test is imported from src/lib/sims/.

Published