This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTs #-} | |
data Expr t where | |
Con :: Int -> Expr Int | |
Add :: Expr Int -> Expr Int -> Expr Int | |
Mult :: Expr Int -> Expr Int -> Expr Int | |
IsZ :: Expr Int -> Expr Bool | |
If :: Expr Bool -> Expr t -> Expr t -> Expr t | |
And :: Expr Bool -> Expr Bool -> Expr Bool | |
Or :: Expr Bool -> Expr Bool -> Expr Bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
Benchmarking of build-in length and custom length function using criterion. | |
Compile with the command: ghc -O3 -W --make lengthbench.hs -o lengthbench | |
Results (timings in seconds, std. dev. negligible): | |
build-in length: | |
1000000 0.004 | |
2000000 0.009 | |
4000000 0.016 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun genVec n = Vector.tabulate(n, fn i => i) | |
local val gen = Random.newgenseed 42.0 in | |
fun random_length () = Random.range(500, 200*16192) gen | |
fun range rng = let val f = Random.range rng in fn () => f gen end | |
end | |
fun initial n = List.tabulate(n, fn _ => genVec(random_length())) | |
fun split_at i lst = |
NewerOlder