Skip to content

Commit

Permalink
Benchmark run error json decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
tbidne committed Feb 26, 2025
1 parent 80a3fff commit bb2002f
Show file tree
Hide file tree
Showing 12 changed files with 295 additions and 136 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on: # yamllint disable-line rule:truthy rule:comments
push:
branches:
- main
- bench3

pull_request:
branches:
Expand Down
12 changes: 11 additions & 1 deletion bench/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import Prelude (IO)
main :: IO ()
main =
defaultMain
[ benchMkSomeRuns
[ benchMkSomeRuns,
benchMkSomeRunsError
]

benchMkSomeRuns :: Benchmark
Expand All @@ -35,6 +36,15 @@ benchMkSomeRuns =
runs_10_000_bs = Utils.genRunsJson 10_000
}

benchMkSomeRunsError :: Benchmark
benchMkSomeRunsError =
bgroup
"decode_runs_error"
[ bench "100" $ nf Utils.decodeErrorRuns (Utils.genOverlappedRunsJson 100),
bench "1_000" $ nf Utils.decodeErrorRuns (Utils.genOverlappedRunsJson 1_000),
bench "10_000" $ nf Utils.decodeErrorRuns (Utils.genOverlappedRunsJson 10_000)
]

data TestParams = MkTestParams
{ runs_100_bs :: ByteString,
runs_1_000_bs :: ByteString,
Expand Down
9 changes: 6 additions & 3 deletions bench/app/baseline_ubuntu-latest_9.10.1_ci.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Name,Mean (ps),2*Stdev (ps),Allocated,Copied,Peak Memory
All.decode_runs.100,1170464768,92895236,4404249,68028,14680064
All.decode_runs.1_000,12588304650,1093524670,46192028,1964373,14680064
All.decode_runs.10_000,144816019200,8173693368,494408486,34394061,23068672
All.decode_runs.100,1141984512,92270534,4404249,68072,15728640
All.decode_runs.1_000,12149009212,560259352,46192075,1955515,22020096
All.decode_runs.10_000,142120749200,5319146876,494379316,33538939,36700160
All.decode_runs_error.100,1109557006,88769046,4194906,73435,36700160
All.decode_runs_error.1_000,11064466050,1047181490,40628640,1758313,36700160
All.decode_runs_error.10_000,118826748200,6003562562,409215724,23484553,36700160
68 changes: 49 additions & 19 deletions bench/app/baseline_ubuntu-latest_9.10.1_ci.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions bench/app/baseline_ubuntu-latest_9.12.1_ci.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Name,Mean (ps),2*Stdev (ps),Allocated,Copied,Peak Memory
All.decode_runs.100,1213885100,109742218,4373774,64872,13631488
All.decode_runs.1_000,12838660112,214231634,45890472,1945291,13631488
All.decode_runs.10_000,147347130200,4950455044,491766880,34433256,22020096
All.decode_runs.100,1217060631,92805122,4373787,64867,15728640
All.decode_runs.1_000,12992771700,1241498928,45892229,1913859,20971520
All.decode_runs.10_000,146792021200,7187489898,491756346,34186985,38797312
All.decode_runs_error.100,1116745750,93129994,4164144,565,38797312
All.decode_runs_error.1_000,11852523300,1148590528,40328875,1811524,38797312
All.decode_runs_error.10_000,124032254200,3600854750,406189652,25159180,38797312
68 changes: 49 additions & 19 deletions bench/app/baseline_ubuntu-latest_9.12.1_ci.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 21 additions & 4 deletions bench/fit/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,37 @@ main =
defaultMain
$ testGroup
"Complexity tests"
[testComplexity]
[ testRunsDecodeComplexity,
testRunsDecodeOverlappedComplexity
]

testComplexity :: TestTree
testComplexity = testCase "Decode runs is linear" $ do
testRunsDecodeComplexity :: TestTree
testRunsDecodeComplexity = testCase "Decode runs is linear" $ do
c <- measureGenDecode
-- This is too flaky to have the assertion be an actual test, so we
-- just run it and print the result if it's different. We keep it as
-- a test, however, so that CI verifies it at least runs.
unless (Fit.isLinear c) $ do
IO.putStrLn $ "Assumed linear but guessed: " ++ show c
IO.putStrLn $ "Predicted linear but guessed: " ++ show c

testRunsDecodeOverlappedComplexity :: TestTree
testRunsDecodeOverlappedComplexity = testCase desc $ do
c <- measureGenDecodeOverlapped
unless (Fit.isLinear c) $ do
IO.putStrLn $ "Predicted linear but guessed: " ++ show c
where
desc = "Decode overlapped runs is linear"

measureGenDecode :: IO Complexity
measureGenDecode =
Fit.fit
$ Fit.mkFitConfig
(Utils.genAndDecodeRuns)
(10, 10_000)

measureGenDecodeOverlapped :: IO Complexity
measureGenDecodeOverlapped =
Fit.fit
$ Fit.mkFitConfig
(Utils.genAndDecodeOverlappedRuns)
(10, 10_000)
Loading

0 comments on commit bb2002f

Please sign in to comment.