Skip to content

Commit 57155f3

Browse files
authored
Merge pull request #1620 from input-output-hk/paweljakubas/latency-benchmarks-second-look
Latency benchmarks second look
2 parents 71208af + 1a9d2f7 commit 57155f3

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

lib/byron/bench/Latency.hs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ main = withUtf8Encoding $ withLatencyLogging $ \logging tvar ->
146146
fmtLn "\n"
147147
fmtLn walletName
148148

149+
fmtTitle "Non-cached run"
150+
runBareScenario logging tvar
151+
149152
fmtTitle "Latencies for 2 fixture wallets scenario"
150153
runScenario logging tvar (nFixtureWallet 2 fixtureByronWallet)
151154

@@ -313,17 +316,20 @@ main = withUtf8Encoding $ withLatencyLogging $ \logging tvar ->
313316
(Link.getTransactionFee @'Byron wal1) Default payload
314317
fmtResult "postTransactionFee " t6
315318

316-
-- this one is to have comparable results from first to last measurement
317-
-- otherwise the first one would be without cashing in contrast to other
318-
-- measurements
319-
_t7bare <- measureApiLogs tvar $ request @ApiNetworkInformation ctx
320-
Link.getNetworkInfo Default Empty
321319
t7 <- measureApiLogs tvar $ request @ApiNetworkInformation ctx
322320
Link.getNetworkInfo Default Empty
323321
fmtResult "getNetworkInfo " t7
324322

325323
pure ()
326324

325+
runBareScenario logging tvar = benchWithServer logging $ \ctx -> do
326+
-- this one is to have comparable results from first to last measurement
327+
-- in runScenario
328+
t <- measureApiLogs tvar $ request @ApiNetworkInformation ctx
329+
Link.getNetworkInfo Default Empty
330+
fmtResult "getNetworkInfo " t
331+
pure ()
332+
327333
meanAvg :: [NominalDiffTime] -> Double
328334
meanAvg ts = sum (map realToFrac ts) * 1000 / fromIntegral (length ts)
329335

lib/jormungandr/test/bench/Latency.hs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ import qualified Network.HTTP.Types.Status as HTTP
134134

135135
main :: forall t n. (t ~ Jormungandr, n ~ 'Testnet 0) => IO ()
136136
main = withUtf8Encoding $ withLatencyLogging $ \logging tvar -> do
137+
138+
fmtLn "Non-cached run"
139+
runBareScenario logging tvar
140+
137141
fmtLn "Latencies for 2 fixture wallets scenario"
138142
runScenario logging tvar (nFixtureWallet 2)
139143

@@ -355,18 +359,21 @@ main = withUtf8Encoding $ withLatencyLogging $ \logging tvar -> do
355359

356360
fmtResult "listStakePools " t7
357361

358-
-- this one is to have comparable results from first to last measurement
359-
-- otherwise the first one would be without cashing in contrast to other
360-
-- measurements
361-
_t8bare <- measureApiLogs tvar $ request @ApiNetworkInformation ctx
362-
Link.getNetworkInfo Default Empty
363362
t8 <- measureApiLogs tvar $ request @ApiNetworkInformation ctx
364363
Link.getNetworkInfo Default Empty
365364

366365
fmtResult "getNetworkInfo " t8
367366

368367
pure ()
369368

369+
runBareScenario logging tvar = benchWithServer logging $ \ctx -> do
370+
-- this one is to have comparable results from first to last measurement
371+
-- in runScenario
372+
t <- measureApiLogs tvar $ request @ApiNetworkInformation ctx
373+
Link.getNetworkInfo Default Empty
374+
fmtResult "getNetworkInfo " t
375+
pure ()
376+
370377
meanAvg :: [NominalDiffTime] -> Double
371378
meanAvg ts = sum (map realToFrac ts) * 1000 / fromIntegral (length ts)
372379

0 commit comments

Comments
 (0)