File: ParserBenchmarks.hs

package info (click to toggle)
haskell-futhark 0.25.32-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 18,236 kB
  • sloc: haskell: 100,484; ansic: 12,100; python: 3,440; yacc: 785; sh: 561; javascript: 558; lisp: 399; makefile: 277
file content (23 lines) | stat: -rw-r--r-- 672 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Language.Futhark.ParserBenchmarks (benchmarks) where

import Criterion (Benchmark, bench, bgroup, whnf)
import Data.Either (fromRight)
import Data.Text qualified as T
import Futhark.Util (showText)
import Language.Futhark.Parser (parseExp)

bigArray :: Int -> T.Text
bigArray n = "[" <> T.intercalate "," (map ((<> "i32") . showText) [0 .. n - 1]) <> "]"

benchmarks :: Benchmark
benchmarks =
  bgroup
    "Language.Futhark.Parser"
    [ benchIntArray 10000,
      benchIntArray 100000,
      benchIntArray 1000000
    ]
  where
    benchIntArray n =
      bench ("[" <> show n <> "]i32") $
        whnf (fromRight (error "parse error") . parseExp "") (bigArray n)