Skip to content

Commit

Permalink
Add some benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed Feb 22, 2019
1 parent 7ee8442 commit 5379f1c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
20 changes: 20 additions & 0 deletions benchmarks/bench.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{-# LANGUAGE OverloadedStrings #-}

import Criterion.Main
import Data.Aeson (Value (..))
import Expr (Expr (..))
import Fake (eval, runFakeT)


exec :: Expr -> IO Value
exec expr = runFakeT (Just 1) (eval expr)


main :: IO ()
main = defaultMain
[ bgroup "ids" [ bench "ulid" $ nfIO (exec "ulid")
, bench "uuid1" $ nfIO (exec "uuid1")
, bench "uuid4" $ nfIO (exec "uuid4") ]
, bgroup "numbers" [ bench "randomInt-0-100" $ nfIO (exec "randomInt(0, 100)" )
, bench "randomInt-0-1000" $ nfIO (exec "randomInt(0, 1000)" ) ]
]
9 changes: 9 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ tests:
- -with-rtsopts=-N
dependencies:
- fake-json

fake-json-doctest:
main: doctests.hs
source-dirs: tests
Expand All @@ -82,6 +83,14 @@ tests:
- Glob
- doctest

benchmarks:
fake-json-benchmarks:
main: bench.hs
source-dirs: benchmarks
dependencies:
- fake-json
- criterion

flags:
static:
description: Pass -static to ghc when linking the binary.
Expand Down

0 comments on commit 5379f1c

Please sign in to comment.