24 lines
982 B
TypeScript
24 lines
982 B
TypeScript
import { expect, it } from 'vitest'
|
|
import { routeAll, type RouteInput } from '../app/lib/logic/routing'
|
|
|
|
it('routes 400 crowded wires fast enough to redraw while dragging', () => {
|
|
const inputs: RouteInput[] = []
|
|
const bodies = []
|
|
for (let i = 0; i < 400; i++) {
|
|
const col = i % 20
|
|
const row = Math.floor(i / 20)
|
|
// Sources in a column on the left, targets scattered: many wires want the same columns.
|
|
inputs.push({ id: `w${i}`, net: `n${i % 150}`, a: [col * 3, row * 3], b: [col * 3 + 8 + (i % 5), row * 3 + ((i * 7) % 11) - 5] })
|
|
if (i % 4 === 0) bodies.push({ x: col * 3 + 4, y: row * 3 - 1, w: 2, h: 2 })
|
|
}
|
|
// The best of three: other tests running at the same time can slow one run down.
|
|
let ms = Infinity
|
|
for (let k = 0; k < 3; k++) {
|
|
const t = performance.now()
|
|
routeAll(inputs, bodies, [])
|
|
ms = Math.min(ms, performance.now() - t)
|
|
}
|
|
console.log(`routeAll(400 wires): ${ms.toFixed(1)} ms`)
|
|
expect(ms).toBeLessThan(250)
|
|
})
|