Browse Source

benchmarks

master
parent
commit
48d94fee6d
Signed by: Yann Esposito (Yogsototh) <yann.esposito@gmail.com> GPG Key ID: 7B19A4C650D59646
4 changed files with 29 additions and 5 deletions
  1. 5
    0
      .dir-locals.el
  2. 2
    0
      human-friendly-id-gen.cabal
  3. 1
    0
      package.yaml
  4. 21
    5
      src-benchmark/Main.hs

+ 5
- 0
.dir-locals.el View File

@@ -0,0 +1,5 @@
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((haskell-mode
(intero-targets "human-friendly-id-gen:lib" "human-friendly-id-gen:exe:hfig" "human-friendly-id-gen:test:human-friendly-id-gen-doctest" "human-friendly-id-gen:test:human-friendly-id-gen-test" "human-friendly-id-gen:bench:human-friendly-id-gen-benchmark")))

+ 2
- 0
human-friendly-id-gen.cabal View File

@@ -2,7 +2,7 @@
--
-- see: https://github.com/sol/hpack
--
-- hash: 5be2664cdea2186d72a0e88938c79a9c59698ad4464b107909e4add64ff85b0c

name: human-friendly-id-gen
version: 0.1.0.0
@@ -113,4 +113,5 @@ benchmark human-friendly-id-gen-benchmark
, criterion >=1.1
, human-friendly-id-gen
, protolude
, vector
default-language: Haskell2010

+ 1
- 0
package.yaml View File

@@ -82,5 +82,6 @@ benchmarks:
- -with-rtsopts=-N
dependencies:
- criterion >=1.1
- vector
- human-friendly-id-gen
stability: alpha (experimental)

+ 21
- 5
src-benchmark/Main.hs View File

@@ -1,9 +1,25 @@
import Protolude
import Protolude

import Criterion
import Criterion.Main
import Criterion
import Criterion.Main
import qualified Data.Vector as V

import Lib (inc)
import qualified HFIG.Dictionary as Dict
import qualified HFIG.Lovecraftian as Lov
import qualified HFIG.Short as Short

main :: IO ()
main = defaultMain [bench "inc 41" (whnf inc (41 :: Int))]
main = do
englishDict <- Dict.dictionaryFromFile "dictionaries/english.txt"
putText $ "loaded english Dict: " <> (show (V.length englishDict) :: Text)
genericDict <- Dict.dictionaryFromFile "dictionaries/generic.txt"
putText $ "loaded generic Dict: " <> (show (V.length genericDict) :: Text)
defaultMain [ bench "short idgen (10)" (nfIO (Short.idgen 10))
, bench "short idgen (100)" (nfIO (Short.idgen 100))
, bench "lovecraftian idgen (1)" (nfIO (Lov.idgen 1))
, bench "lovecraftian idgen (10)" (nfIO (Lov.idgen 10))
, bench "dictionary idgen (english 3)"
(nfIO (Dict.idgen englishDict 3))
, bench "dictionary idgen (generic 3)"
(nfIO (Dict.idgen genericDict 3))
]

Loading…
Cancel
Save