packages feed

advent-of-code-ocr-0.1.0.0: bench/bench.hs

{-# LANGUAGE QuasiQuotes #-}

import           Advent.OCR
import           Criterion.Main
import           Data.Set       (Set)
import           Text.Heredoc
import qualified Data.Set       as S

main :: IO ()
main = defaultMainWith defaultConfig [
    bench "small font" $ nf parseLetters smallFont
  , bench "large font" $ nf parseLetters bigFont
  ]

smallFont :: Set (Int, Int)
smallFont = parseAsciiMap (S.singleton '#') $ drop 1 [here|
####...##.#..#.###..#..#..##..###..#...
...#....#.#..#.#..#.#.#..#..#.#..#.#...
..#.....#.####.#..#.##...#....#..#.#...
.#......#.#..#.###..#.#..#....###..#...
#....#..#.#..#.#.#..#.#..#..#.#....#...
####..##..#..#.#..#.#..#..##..#....####
|]

bigFont :: Set (Int, Int)
bigFont = parseAsciiMap (S.singleton '#') $ drop 1 [here|
..##....#....#..######..#.......#........####.....##....#.....
.#..#...#....#.......#..#.......#.......#....#...#..#...#.....
#....#..#....#.......#..#.......#.......#.......#....#..#.....
#....#..#....#......#...#.......#.......#.......#....#..#.....
#....#..######.....#....#.......#.......#.......#....#..#.....
######..#....#....#.....#.......#.......#.......######..#.....
#....#..#....#...#......#.......#.......#.......#....#..#.....
#....#..#....#..#.......#.......#.......#.......#....#..#.....
#....#..#....#..#.......#.......#.......#....#..#....#..#.....
#....#..#....#..######..######..######...####...#....#..######
|]