packages feed

bimaps 0.0.0.3 → 0.0.0.4

raw patch · 5 files changed

+111/−78 lines, 5 filesdep +test-frameworkdep +test-framework-quickcheck2dep +test-framework-thdep ~basedep ~cerealPVP ok

version bump matches the API change (PVP)

Dependencies added: test-framework, test-framework-quickcheck2, test-framework-th

Dependency ranges changed: base, cereal

API changes (from Hackage documentation)

Files

bimaps.cabal view
@@ -1,5 +1,5 @@ Name:           bimaps-Version:        0.0.0.3+Version:        0.0.0.4 License:        BSD3 License-file:   LICENSE Author:         Christian Hoener zu Siederdissen@@ -37,12 +37,11 @@   build-depends: base                     >= 4.7      && < 4.9                , aeson                    >= 0.8      && < 0.11                , binary                   >= 0.7      && < 0.8-               , cereal                   >= 0.4      && < 0.5+               , cereal                   >= 0.4      && < 0.6                , containers               >= 0.5      && < 0.6                , deepseq                  >= 1.3      && < 1.5                , hashable                 >= 1.2      && < 1.3                , primitive                >= 0.5      && < 0.7-               , QuickCheck               >= 2.7      && < 2.9                , storable-tuple           >= 0.0.2    && < 0.0.3                , unordered-containers     >= 0.2.5    && < 0.2.6                , vector                   >= 0.10     && < 0.12@@ -69,7 +68,7 @@                , mwc-random  >= 0.13    && < 0.14                , vector   hs-source-dirs:-    src+    tests   main-is:     Benchmark.hs   default-language:@@ -85,6 +84,28 @@     -funbox-strict-fields     -funfolding-use-threshold1000     -funfolding-keeness-factor1000++++test-suite properties+  type:+    exitcode-stdio-1.0+  main-is:+    properties.hs+  ghc-options:+    -threaded -rtsopts -with-rtsopts=-N+  hs-source-dirs:+    tests+  default-language:+    Haskell2010+  default-extensions: TemplateHaskell+                    , ScopedTypeVariables+  build-depends: base+               , bimaps+               , QuickCheck                   >= 2.7  && < 2.9+               , test-framework               >= 0.8  && < 0.9+               , test-framework-quickcheck2   >= 0.3  && < 0.4+               , test-framework-th            >= 0.2  && < 0.3   
changelog.md view
@@ -1,3 +1,7 @@+0.0.0.4++- stub properties+ 0.0.0.3 ------- 
− src/Benchmark.hs
@@ -1,74 +0,0 @@--module Main where--import           Criterion.Main-import qualified Data.Vector.Unboxed as VU-import qualified Data.Vector.Generic as VG-import qualified Data.Vector as VV-import           Text.Printf-import           Data.Tuple (swap)-import           Control.Applicative ((<$>))-import           System.Random.MWC-import           Control.DeepSeq--import qualified Data.Bijection.Vector as BV-import qualified Data.Bijection.Vector.Unboxed as BU-import qualified Data.Bijection.Vector.Storable as BS-import qualified Data.Bijection.Map as BM-import qualified Data.Bijection.Hash as HS-import qualified Data.Bijection.Class as B----runLookupBench xs' z = bench s $ whnf allLR xs'-  where s = printf "%5d" (B.size z)-        lL k = B.lookupL z k-        lR k = B.lookupR z k-        allL xs = VV.foldl' f 0 . VV.map lL . VG.convert $ xs-        allR xs = VV.foldl' f 0 . VV.map lR . VG.convert $ xs-        allLR xs = allL xs + allR xs-        f k (Just (!x)) = max k x-        f k _           = k-{-# INLINE runLookupBench #-}--benchLookup xs z = allLR -- bench s $ whnf allLR xs'-  where lL k = B.lookupL z k-        lR k = B.lookupR z k-        allL = VV.foldl' f 0 . VV.map lL . VG.convert $ xs-        allR = VV.foldl' f 0 . VV.map lR . VG.convert $ xs-        allLR = allL + allR-        f k (Just (!x)) = max k x-        f k _           = k-{-# INLINE benchLookup #-}--benchVU :: VU.Vector Int -> BU.Bimap Int Int -> Int-benchVU = benchLookup-{-# NOINLINE benchVU #-}--benchBM :: VU.Vector Int -> BM.Bimap Int Int -> Int-benchBM = benchLookup-{-# NOINLINE benchBM #-}--main :: IO ()-main = do-  lkup :: VU.Vector Int <- withSystemRandom . asGenIO $ \gen -> uniformVector gen 10-  inputs :: [[Int]] <- mapM (\l -> withSystemRandom . asGenIO $ \gen -> VU.toList <$> uniformVector gen l) [1, 5, 10, 50, 100, 1000] -- [1,10,100,1000,10000]-  let zVV :: [BV.Bimap Int Int] = map (\i -> B.fromList $ zip i i) inputs-  let zVU :: [BU.Bimap Int Int] = map (\i -> B.fromList $ zip i i) inputs-  let zVS :: [BS.Bimap Int Int] = map (\i -> B.fromList $ zip i i) inputs-  let zMS :: [BM.Bimap Int Int] = map (\i -> B.fromList $ zip i i) inputs-  let zHS :: [HS.Bimap Int Int] = map (\i -> B.fromList $ zip i i) inputs-  deepseq (lkup,inputs,zVV,zVU,zVS,zMS,zHS) `seq` defaultMain-    [ bgroup "5"-      [ bench "vector/ unboxed" $ whnf (benchVU lkup) (zVU !! 1)-      , bench "   map/  strict" $ whnf (benchBM lkup) (zMS !! 1)-      ]-    , bgroup "by type"---      [ bgroup "vector/    boxed" (map (runLookupBench lkup) zVV)---      , bgroup "vector/ storable" (map (runLookupBench lkup) zVS)-      [ bgroup "vector/  unboxed" (map (runLookupBench lkup) zVU)-      , bgroup "   map/   strict" (map (runLookupBench lkup) zMS)-      , bgroup "  hash/   strict" (map (runLookupBench lkup) zHS)-      ]-    ]-
+ tests/Benchmark.hs view
@@ -0,0 +1,74 @@++module Main where++import           Criterion.Main+import qualified Data.Vector.Unboxed as VU+import qualified Data.Vector.Generic as VG+import qualified Data.Vector as VV+import           Text.Printf+import           Data.Tuple (swap)+import           Control.Applicative ((<$>))+import           System.Random.MWC+import           Control.DeepSeq++import qualified Data.Bijection.Vector as BV+import qualified Data.Bijection.Vector.Unboxed as BU+import qualified Data.Bijection.Vector.Storable as BS+import qualified Data.Bijection.Map as BM+import qualified Data.Bijection.Hash as HS+import qualified Data.Bijection.Class as B++++runLookupBench xs' z = bench s $ whnf allLR xs'+  where s = printf "%5d" (B.size z)+        lL k = B.lookupL z k+        lR k = B.lookupR z k+        allL xs = VV.foldl' f 0 . VV.map lL . VG.convert $ xs+        allR xs = VV.foldl' f 0 . VV.map lR . VG.convert $ xs+        allLR xs = allL xs + allR xs+        f k (Just (!x)) = max k x+        f k _           = k+{-# INLINE runLookupBench #-}++benchLookup xs z = allLR -- bench s $ whnf allLR xs'+  where lL k = B.lookupL z k+        lR k = B.lookupR z k+        allL = VV.foldl' f 0 . VV.map lL . VG.convert $ xs+        allR = VV.foldl' f 0 . VV.map lR . VG.convert $ xs+        allLR = allL + allR+        f k (Just (!x)) = max k x+        f k _           = k+{-# INLINE benchLookup #-}++benchVU :: VU.Vector Int -> BU.Bimap Int Int -> Int+benchVU = benchLookup+{-# NOINLINE benchVU #-}++benchBM :: VU.Vector Int -> BM.Bimap Int Int -> Int+benchBM = benchLookup+{-# NOINLINE benchBM #-}++main :: IO ()+main = do+  lkup :: VU.Vector Int <- withSystemRandom . asGenIO $ \gen -> uniformVector gen 10+  inputs :: [[Int]] <- mapM (\l -> withSystemRandom . asGenIO $ \gen -> VU.toList <$> uniformVector gen l) [1, 5, 10, 50, 100, 1000] -- [1,10,100,1000,10000]+  let zVV :: [BV.Bimap Int Int] = map (\i -> B.fromList $ zip i i) inputs+  let zVU :: [BU.Bimap Int Int] = map (\i -> B.fromList $ zip i i) inputs+  let zVS :: [BS.Bimap Int Int] = map (\i -> B.fromList $ zip i i) inputs+  let zMS :: [BM.Bimap Int Int] = map (\i -> B.fromList $ zip i i) inputs+  let zHS :: [HS.Bimap Int Int] = map (\i -> B.fromList $ zip i i) inputs+  deepseq (lkup,inputs,zVV,zVU,zVS,zMS,zHS) `seq` defaultMain+    [ bgroup "5"+      [ bench "vector/ unboxed" $ whnf (benchVU lkup) (zVU !! 1)+      , bench "   map/  strict" $ whnf (benchBM lkup) (zMS !! 1)+      ]+    , bgroup "by type"+--      [ bgroup "vector/    boxed" (map (runLookupBench lkup) zVV)+--      , bgroup "vector/ storable" (map (runLookupBench lkup) zVS)+      [ bgroup "vector/  unboxed" (map (runLookupBench lkup) zVU)+      , bgroup "   map/   strict" (map (runLookupBench lkup) zMS)+      , bgroup "  hash/   strict" (map (runLookupBench lkup) zHS)+      ]+    ]+
+ tests/properties.hs view
@@ -0,0 +1,8 @@++module Main where++++main :: IO ()+main = return ()+