Created
November 1, 2016 20:45
-
-
Save gregnwosu/432a0e493e5aa520270a354e60c9d70e to your computer and use it in GitHub Desktop.
sequence slower to index?
This file contains 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
module SequenceTest where | |
import Criterion.Main | |
import qualified Data.Sequence as SQ | |
s :: SQ.Seq Int | |
s = SQ.fromList [1..9100] | |
lists :: [[Int]] | |
lists = replicate 10 [1..1000000] | |
seqs :: [SQ.Seq Int] | |
seqs = replicate 10 (SQ.fromList [1..1000000]) | |
l1 = [0] | |
s1 = SQ.singleton 0 | |
l :: [Int] | |
l = [1..9100] | |
main = | |
defaultMain | |
[ | |
-- bench "list concat" $ nf (l ++ ) l1, | |
-- bench "seq concat " $ nf (s SQ.>< ) s1, | |
-- bench "list mconcat " $ nf mconcat lists, | |
-- bench "seqs mconcat" $ nf mconcat seqs, | |
bench "list index" $ whnf (\xs -> xs !! 9001) l, | |
bench "seq index" $ whnf (`SQ.index` 9001) s | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment