For workers on a shared line (poweredge-kantoor: 160 Mbit/s): the range stream is read at most at the cap, TCP holds the coordinator back. The cap is the node's, split over its processes (also EDGE_MAX_MBIT). REBUILD.md: where workers run (connections set the speed; remote workers take CPU off homelab). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
17 lines
686 B
TypeScript
17 lines
686 B
TypeScript
import { test } from '@japa/runner'
|
|
import { throttle } from '#lib/edge/index'
|
|
|
|
test.group('edge / throttle', () => {
|
|
test('passes everything on, at most the given rate after the first second', async ({ assert }) => {
|
|
const pieces = Array.from({ length: 30 }, (_, i) => new Uint8Array(1000).fill(i))
|
|
const started = Date.now()
|
|
const out: Uint8Array[] = []
|
|
// 30,000 bytes at 20,000 B/s: the first 20,000 at once, the rest over ~0.5 s.
|
|
for await (const piece of throttle(pieces, 20_000)) out.push(piece)
|
|
const seconds = (Date.now() - started) / 1000
|
|
assert.deepEqual(out, pieces)
|
|
assert.isAtLeast(seconds, 0.45)
|
|
assert.isBelow(seconds, 1.2)
|
|
})
|
|
})
|