|
1 | 1 | --!strict |
2 | 2 | --!optimize 2 |
3 | | --- Client-side benchmark runner. Drains s2c, then drives c2s. |
| 3 | +-- Client: receive s2c, then drive c2s. |
4 | 4 |
|
5 | 5 | local ReplicatedStorage = game:GetService("ReplicatedStorage") |
| 6 | +local Workspace = game:GetService("Workspace") |
6 | 7 |
|
7 | | -local LyncFolder = ReplicatedStorage:WaitForChild("Lync") |
8 | | -local Harness = require(LyncFolder.bench.Harness) |
9 | | -local Lync = require(LyncFolder) |
10 | | -local Scenarios = require(LyncFolder.bench.Scenarios) |
11 | | - |
12 | | --- Constants -------------------------------------------------------------- |
| 8 | +local Lync = require(ReplicatedStorage:WaitForChild("Lync")) |
| 9 | +local Harness = require(ReplicatedStorage.Lync.bench.Harness) |
| 10 | +local Scenarios = require(ReplicatedStorage.Lync.bench.Scenarios) |
13 | 11 |
|
14 | 12 | local bench = Scenarios.bench |
15 | 13 |
|
16 | | -local function noop(): () end |
17 | | - |
18 | | ---[[ |
19 | | - Client must mirror the server's channelMaxSize. Server and client run |
20 | | - as separate Lua VMs with independent module state, so configure() on |
21 | | - the server doesn't propagate. Without this, the client's buffer caps |
22 | | - at the 256KB default and the comparison test (1000 fires of 601B |
23 | | - entity arrays = 601KB) overflows during c2s. |
24 | | -]] |
25 | | -Lync.configure({ channelMaxSize = bench.channelMaxSize }) |
26 | | -Lync.start() |
27 | | - |
28 | | --- Attach receivers so server -> client throughput isn't held back by |
29 | | --- serializing into uncollected channels. |
30 | | -for _, packet in Scenarios.packets do |
31 | | - packet:on(noop) |
| 14 | +-- Minimise render contention so frame budget reflects bench CPU only. |
| 15 | +if Workspace.CurrentCamera then |
| 16 | + Workspace.CurrentCamera.FieldOfView = 1 |
32 | 17 | end |
33 | 18 |
|
34 | | --- Wait through s2c phase ------------------------------------------------- |
| 19 | +Lync.configure({ channelMaxSize = bench.channelMaxSize, stats = true }) |
| 20 | +Lync.start() |
35 | 21 |
|
36 | 22 | Scenarios.handshake.ServerCpuDone:wait() |
37 | 23 | Scenarios.handshake.ClientReady:send(true) |
38 | 24 | Scenarios.handshake.ServerSwap:wait() |
39 | 25 |
|
40 | | --- c2s throughput --------------------------------------------------------- |
41 | | - |
42 | | -Harness.header("Network Throughput (client -> server)") |
| 26 | +-- Blink-comparable c2s --------------------------------------------------- |
43 | 27 |
|
44 | | -Harness.section(string.format("%d fires/frame, %ds per case", bench.smallFires, bench.netDuration)) |
45 | | -for _, case in Scenarios.netCases do |
46 | | - local packet, data = case.packet, case.data |
47 | | - Harness.benchNetwork(case.label, case.fires, bench.netDuration, function() |
48 | | - packet:send(data) |
49 | | - end) |
| 28 | +Harness.header(string.format( |
| 29 | + "Cross-library reference (c2s, %d fires/frame, %ds)", |
| 30 | + bench.blinkFiresPerFrame, bench.blinkSeconds |
| 31 | +)) |
| 32 | +for _, case in Scenarios.blinkCases do |
| 33 | + Harness.throughput(case.label, bench.blinkFiresPerFrame, bench.blinkSeconds, case.pool, |
| 34 | + function(data) case.packet:send(data) end) |
| 35 | + task.wait(2) |
50 | 36 | end |
51 | | -Harness.sectionEnd() |
52 | | - |
53 | | --- Cross-library comparison (client -> server) ---------------------------- |
54 | 37 |
|
55 | | -Harness.header("Cross-Library Comparison (client -> server)") |
| 38 | +-- Extended c2s ----------------------------------------------------------- |
56 | 39 |
|
57 | | -for _, case in Scenarios.compCases do |
58 | | - Harness.section( |
59 | | - string.format("%s, %d/frame, %ds", case.title, bench.compFires, bench.compDuration) |
60 | | - ) |
61 | | - local packet, data = case.packet, case.data |
62 | | - Harness.benchComparison( |
63 | | - case.label, |
64 | | - bench.compFires, |
65 | | - bench.compDuration, |
66 | | - bench.compFps, |
67 | | - function() |
68 | | - packet:send(data) |
69 | | - end |
70 | | - ) |
71 | | - Harness.sectionEnd() |
| 40 | +Harness.header(string.format( |
| 41 | + "Extended (c2s, %d fires/frame, %ds)", |
| 42 | + bench.extendedFiresPerFrame, bench.extendedSeconds |
| 43 | +)) |
| 44 | +for _, case in Scenarios.extendedCases do |
| 45 | + Harness.throughput(case.label, bench.extendedFiresPerFrame, bench.extendedSeconds, case.pool, |
| 46 | + function(data) case.packet:send(data) end) |
| 47 | + task.wait(1) |
72 | 48 | end |
73 | 49 |
|
74 | 50 | Scenarios.handshake.ClientDone:send(true) |
0 commit comments