test: load-insensitive tviews perf gate; env note
This commit is contained in:
+35
-2
@@ -1,8 +1,10 @@
|
||||
## Vision microbench: devbox run bench (nim c -d:release -r tools/bench.nim; log: results/bench.log).
|
||||
## Vision and egress microbench: devbox run bench (nim c -d:release -r tools/bench.nim; log: results/bench.log).
|
||||
## No timing code lives in server/: this harness times from outside with O(1) accumulators (sum, worst), no sample arrays.
|
||||
## Targets (DESIGN 5.3 / 13 M2, PROPOSED): polygon + cells <= 0.451 ms avg on the prototype scene; polygon < 1 ms avg on 5k walls.
|
||||
import std/[json, monotimes, times, strformat, os, math]
|
||||
## The egress rows record the absolute averages the in-process gate (tests/tviews.nim, TESTING 5.3) deliberately does not assert.
|
||||
import std/[json, monotimes, times, strformat, os, math, sets, tables]
|
||||
import geometry, moverules
|
||||
import characters, props, tokens, views, vision, world
|
||||
import scenegen
|
||||
import ../tests/[refold, testutil]
|
||||
|
||||
@@ -72,5 +74,36 @@ proc big(label: string, world: float) =
|
||||
if label == "5k sparse": target("polygon, 5k-wall scene", po, 1.0)
|
||||
big("5k sparse", 16384)
|
||||
big("5k dense", 4096)
|
||||
echo "== egress (#28: 6 players x 40 encountered entries, 262144 explored cells) =="
|
||||
proc egressStore(cells: int): ref ContextStore =
|
||||
var tokens: seq[TokenRec]
|
||||
for i in 0 ..< 6:
|
||||
tokens.add TokenRec(id: "t" & $(i + 2), scene: 1, kind: "npc", descriptiveName: "t",
|
||||
actualName: "T", pos: (400.0 + float(i) * 10, 400), owner: i + 2,
|
||||
flags: %*{"vision": true}, props: newProps())
|
||||
for e in 0 ..< 40:
|
||||
tokens.add TokenRec(id: "e" & $e, scene: 1, kind: "npc", descriptiveName: "a thing",
|
||||
actualName: "Thing", pos: (3000.0 + float(e) * 30, 3000), owner: 0,
|
||||
flags: %*{}, props: newProps())
|
||||
result = (ref ContextStore)(scene: SceneRec(id: 1, name: "Scene", w: 4096, h: 4096, tileSize: 32,
|
||||
cell: 32, visionRadiusDefault: 400,
|
||||
tokenRadiusDefault: 20, artVersion: 1, nextWallId: 1,
|
||||
extra: newJObject()), tokens: tokens)
|
||||
for pid in 2 .. 7:
|
||||
var pv: PlayerVision
|
||||
pv.refresh(result.scene, result.tokens, pid)
|
||||
result.visions[pid] = pv
|
||||
for k in 0 ..< cells: result.visions[pid].explored.incl k
|
||||
result.encountered[pid] = initTable[string, EncounteredEntry]()
|
||||
for e in 0 ..< 40:
|
||||
result.encountered[pid]["e" & $e] =
|
||||
EncounteredEntry(entityId: "e" & $e, descriptiveName: "a thing")
|
||||
let egressLarge = egressStore(262144)
|
||||
discard bench("GM egress pass (fresh diff base)", 200, proc(i: int) =
|
||||
var known: Known
|
||||
sink += egressFrames(Recipient(isGm: true, playerId: 1), egressLarge.borrow, known).len)
|
||||
discard bench("player egress pass (fresh diff base)", 200, proc(i: int) =
|
||||
var known: Known
|
||||
sink += egressFrames(Recipient(isGm: false, playerId: 2), egressLarge.borrow, known).len)
|
||||
echo "(sink ", sink, ")"
|
||||
quit(if misses == 0: 0 else: 1)
|
||||
|
||||
Reference in New Issue
Block a user