Skip to content

Commit 9042ec6

Browse files
committed
ye
1 parent 63e7f37 commit 9042ec6

87 files changed

Lines changed: 1553 additions & 1186 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bench/Harness.luau

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,26 @@ end
2626

2727
local function fmtNum(n: number): string
2828
local s = tostring(floor(n))
29-
if #s <= 3 then return s end
29+
if #s <= 3 then
30+
return s
31+
end
3032
local out, rem = {}, #s % 3
31-
if rem > 0 then table.insert(out, s:sub(1, rem)) end
32-
for i = rem + 1, #s, 3 do table.insert(out, s:sub(i, i + 2)) end
33+
if rem > 0 then
34+
table.insert(out, s:sub(1, rem))
35+
end
36+
for i = rem + 1, #s, 3 do
37+
table.insert(out, s:sub(i, i + 2))
38+
end
3339
return table.concat(out, ",")
3440
end
3541

3642
local function fmtTime(us: number): string
37-
if us < 1 then return `{floor(us * 1000 + 0.5)}ns` end
38-
if us < 1000 then return `{round1(us)}us` end
43+
if us < 1 then
44+
return `{floor(us * 1000 + 0.5)}ns`
45+
end
46+
if us < 1000 then
47+
return `{round1(us)}us`
48+
end
3949
return `{round1(us / 1000)}ms`
4050
end
4151

@@ -113,9 +123,12 @@ function Harness.roundTrip(label: string, codec: any, value: any): ()
113123
local decUs = dec / RT_ITERS * 1e6
114124
Harness.row(
115125
format("%s (%dB)", label, n),
116-
format("enc=%-9s dec=%-9s rt/s=%s",
117-
fmtTime(encUs), fmtTime(decUs),
118-
fmtNum(RT_ITERS / (enc + dec)))
126+
format(
127+
"enc=%-9s dec=%-9s rt/s=%s",
128+
fmtTime(encUs),
129+
fmtTime(decUs),
130+
fmtNum(RT_ITERS / (enc + dec))
131+
)
119132
)
120133
end
121134

@@ -165,7 +178,8 @@ function Harness.throughput(
165178
sort(kbps)
166179
Harness.row(
167180
label,
168-
format("fps=%-3d Kbps=%-9s p95=%s",
181+
format(
182+
"fps=%-3d Kbps=%-9s p95=%s",
169183
floor(pct(fps, 50) + 0.5),
170184
format("%.2f", pct(kbps, 50)),
171185
format("%.2f", pct(kbps, 95))

bench/Run.client.luau

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
local ReplicatedStorage = game:GetService("ReplicatedStorage")
66
local Workspace = game:GetService("Workspace")
77

8-
local Lync = require(ReplicatedStorage:WaitForChild("Lync"))
98
local Harness = require(ReplicatedStorage.Lync.bench.Harness)
9+
local Lync = require(ReplicatedStorage:WaitForChild("Lync"))
1010
local Scenarios = require(ReplicatedStorage.Lync.bench.Scenarios)
1111

1212
local bench = Scenarios.bench
@@ -25,25 +25,45 @@ Scenarios.handshake.ServerSwap:wait()
2525

2626
-- Blink-comparable c2s ---------------------------------------------------
2727

28-
Harness.header(string.format(
29-
"Cross-library reference (c2s, %d fires/frame, %ds)",
30-
bench.blinkFiresPerFrame, bench.blinkSeconds
31-
))
28+
Harness.header(
29+
string.format(
30+
"Cross-library reference (c2s, %d fires/frame, %ds)",
31+
bench.blinkFiresPerFrame,
32+
bench.blinkSeconds
33+
)
34+
)
3235
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)
36+
Harness.throughput(
37+
case.label,
38+
bench.blinkFiresPerFrame,
39+
bench.blinkSeconds,
40+
case.pool,
41+
function(data)
42+
case.packet:send(data)
43+
end
44+
)
3545
task.wait(2)
3646
end
3747

3848
-- Extended c2s -----------------------------------------------------------
3949

40-
Harness.header(string.format(
41-
"Extended (c2s, %d fires/frame, %ds)",
42-
bench.extendedFiresPerFrame, bench.extendedSeconds
43-
))
50+
Harness.header(
51+
string.format(
52+
"Extended (c2s, %d fires/frame, %ds)",
53+
bench.extendedFiresPerFrame,
54+
bench.extendedSeconds
55+
)
56+
)
4457
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)
58+
Harness.throughput(
59+
case.label,
60+
bench.extendedFiresPerFrame,
61+
bench.extendedSeconds,
62+
case.pool,
63+
function(data)
64+
case.packet:send(data)
65+
end
66+
)
4767
task.wait(1)
4868
end
4969

bench/Run.server.luau

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
local Players = game:GetService("Players")
66
local ReplicatedStorage = game:GetService("ReplicatedStorage")
77

8-
local Lync = require(ReplicatedStorage:WaitForChild("Lync"))
98
local Harness = require(ReplicatedStorage.Lync.bench.Harness)
9+
local Lync = require(ReplicatedStorage:WaitForChild("Lync"))
1010
local Scenarios = require(ReplicatedStorage.Lync.bench.Scenarios)
1111

1212
local bench = Scenarios.bench
@@ -44,25 +44,45 @@ Scenarios.handshake.ClientReady:wait()
4444

4545
-- Blink-comparable: 1000 fires/frame, 10 s, varying data ----------------
4646

47-
Harness.header(string.format(
48-
"Cross-library reference (s2c, %d fires/frame, %ds)",
49-
bench.blinkFiresPerFrame, bench.blinkSeconds
50-
))
47+
Harness.header(
48+
string.format(
49+
"Cross-library reference (s2c, %d fires/frame, %ds)",
50+
bench.blinkFiresPerFrame,
51+
bench.blinkSeconds
52+
)
53+
)
5154
for _, case in Scenarios.blinkCases do
52-
Harness.throughput(case.label, bench.blinkFiresPerFrame, bench.blinkSeconds, case.pool,
53-
function(data) case.packet:send(data, player) end)
55+
Harness.throughput(
56+
case.label,
57+
bench.blinkFiresPerFrame,
58+
bench.blinkSeconds,
59+
case.pool,
60+
function(data)
61+
case.packet:send(data, player)
62+
end
63+
)
5464
task.wait(2)
5565
end
5666

5767
-- Extended scenarios: 100 fires/frame, vary/stable pairs ----------------
5868

59-
Harness.header(string.format(
60-
"Extended (s2c, %d fires/frame, %ds)",
61-
bench.extendedFiresPerFrame, bench.extendedSeconds
62-
))
69+
Harness.header(
70+
string.format(
71+
"Extended (s2c, %d fires/frame, %ds)",
72+
bench.extendedFiresPerFrame,
73+
bench.extendedSeconds
74+
)
75+
)
6376
for _, case in Scenarios.extendedCases do
64-
Harness.throughput(case.label, bench.extendedFiresPerFrame, bench.extendedSeconds, case.pool,
65-
function(data) case.packet:send(data, player) end)
77+
Harness.throughput(
78+
case.label,
79+
bench.extendedFiresPerFrame,
80+
bench.extendedSeconds,
81+
case.pool,
82+
function(data)
83+
case.packet:send(data, player)
84+
end
85+
)
6686
task.wait(1)
6787
end
6888

0 commit comments

Comments
 (0)