forked from purescript-deprecated/purescript-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Bench.Data.Map where | ||
|
||
import Prelude | ||
import Control.Monad.Eff (Eff) | ||
import Control.Monad.Eff.Console (CONSOLE, log) | ||
import Performance.Minibench (bench) | ||
|
||
import Data.Tuple (Tuple(..)) | ||
import Data.List as L | ||
import Data.Map as M | ||
|
||
benchMap :: Eff (console :: CONSOLE) Unit | ||
benchMap = do | ||
log "insertion benchmark" | ||
benchInsert | ||
|
||
log "" | ||
|
||
log "lookup benchmark" | ||
benchLookup | ||
|
||
benchInsert :: Eff (console :: CONSOLE) Unit | ||
benchInsert = | ||
let natPairs = (flip Tuple) unit <$> L.range 0 999999 | ||
bigMap = M.fromFoldable $ natPairs | ||
in bench \_ -> M.insert 0 unit bigMap | ||
|
||
benchLookup :: Eff (console :: CONSOLE) Unit | ||
benchLookup = | ||
let natPairs = (flip Tuple) unit <$> L.range 0 999999 | ||
bigMap = M.fromFoldable $ natPairs | ||
in bench \_ -> M.lookup 0 bigMap |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Bench.Data.StrMap where | ||
|
||
import Prelude | ||
import Control.Monad.Eff (Eff) | ||
import Control.Monad.Eff.Console (CONSOLE, log) | ||
import Performance.Minibench (bench) | ||
|
||
import Data.Tuple (Tuple(..)) | ||
import Data.List as L | ||
import Data.Map as M | ||
|
||
benchStrMap :: Eff (console :: CONSOLE) Unit | ||
benchStrMap = do | ||
log "insertion benchmark" | ||
benchInsert | ||
|
||
log "" | ||
|
||
log "lookup benchmark" | ||
benchLookup | ||
|
||
benchInsert :: Eff (console :: CONSOLE) Unit | ||
benchInsert = | ||
let natPairs = (flip Tuple) unit <<< show <$> L.range 0 999999 | ||
bigMap = M.fromFoldable $ natPairs | ||
in bench \_ -> M.insert "0" unit bigMap | ||
|
||
benchLookup :: Eff (console :: CONSOLE) Unit | ||
benchLookup = | ||
let natPairs = (flip Tuple) unit <<< show <$> L.range 0 999999 | ||
bigMap = M.fromFoldable $ natPairs | ||
in bench \_ -> M.lookup "0" bigMap |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Bench.Main where | ||
|
||
import Prelude | ||
import Control.Monad.Eff (Eff) | ||
import Control.Monad.Eff.Console (CONSOLE, log) | ||
|
||
import Bench.Data.Map (benchMap) | ||
import Bench.Data.StrMap (benchStrMap) | ||
|
||
main :: Eff (console :: CONSOLE) Unit | ||
main = do | ||
log "Map benchmarks" | ||
log "==============" | ||
benchMap | ||
|
||
log "" | ||
|
||
log "StrMap benchmarks" | ||
log "====================" | ||
benchStrMap |
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
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