Files
aoc-2022/bench/Bench.hs

40 lines
919 B
Haskell
Raw Normal View History

2023-08-30 09:32:12 +02:00
module Main where
2023-08-30 13:30:36 +02:00
import Lib
import Criterion
import Criterion.Main
paths :: [FilePath]
paths =
[ "./data/01.in"
, "./data/02.in"
, "./data/03.in"
, "./data/04.in"
, "./data/05.in"
2023-08-31 08:34:48 +02:00
, "./data/06.in"
2023-08-31 08:41:20 +02:00
, "./data/07.in"
2023-09-07 08:20:07 +02:00
, "./data/08.in"
2023-08-30 13:30:36 +02:00
]
solutions :: [(Integer, [Day], FilePath)]
2023-08-30 13:39:18 +02:00
solutions = filter (\(n, d, p) -> not (null d)) $ zip3 [1 ..] days paths
2023-08-30 13:30:36 +02:00
makeGroup :: (Show a) => (a, [Day], FilePath) -> Benchmark
makeGroup (n, d, f) =
bgroup ("Day " ++ show n) (makeBenchmarks f d)
makeBenchmarks :: FilePath -> [Day] -> [Benchmark]
makeBenchmarks f = zipWith name [1 ..] . map (makeBench f)
where
name :: Int -> Benchmarkable -> Benchmark
name n = bench ("v" ++ show n)
makeBench :: FilePath -> Day -> Benchmarkable
makeBench f d = nfAppIO (fmap show . run d) f
groups :: [Benchmark]
groups = map makeGroup solutions
2023-08-30 09:32:12 +02:00
2023-08-30 13:39:18 +02:00
main :: IO ()
main = defaultMain groups