bencoding 0.4.4.0 → 0.4.5.0
raw patch · 2 files changed
+30/−8 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.BEncode.BDict: Cons :: !BKey -> a -> !(BDictMap a) -> BDictMap a
+ Data.BEncode.BDict: Cons :: !BKey -> a -> !BDictMap a -> BDictMap a
Files
- bench/Main.hs +14/−4
- bencoding.cabal +16/−4
bench/Main.hs view
@@ -16,6 +16,7 @@ module Main (main) where import Control.DeepSeq+import Control.Exception import Data.Attoparsec.ByteString as Atto import Data.ByteString as BS import qualified Data.ByteString.Lazy as BL@@ -28,12 +29,14 @@ import GHC.Generics import "bencode" Data.BEncode as A-import Data.AttoBencode as B-import Data.AttoBencode.Parser as B import "bencoding" Data.BEncode as C import "bencoding" Data.BEncode.Internal as C import "bencoding" Data.BEncode.Types as C +#ifdef BENCHMARK_ATTOBENCODE+import Data.AttoBencode as B+import Data.AttoBencode.Parser as B+#endif instance NFData A.BEncode where rnf (A.BInt i) = rnf i@@ -41,11 +44,13 @@ rnf (A.BList l) = rnf l rnf (A.BDict m) = rnf m +#ifdef BENCHMARK_ATTOBENCODE instance NFData B.BValue where rnf (B.BInt i) = rnf i rnf (B.BString s) = rnf s rnf (B.BList l) = rnf l rnf (B.BDict d) = rnf d+#endif getRight :: Either String a -> a getRight = either error id@@ -125,8 +130,7 @@ torrentFile <- BS.readFile path let lazyTorrentFile = BL.fromChunks [torrentFile] - case rnf (torrentFile, lazyTorrentFile) of- () -> return ()+ evaluate $ rnf (torrentFile, lazyTorrentFile) withArgs args $ defaultMain@@ -139,15 +143,19 @@ , let Just v = A.bRead lazyTorrentFile in bench "encode/bencode" $ nf A.bPack v+#ifdef BENCHMARK_ATTOBENCODE , let Right v = Atto.parseOnly bValue torrentFile in bench "encode/AttoBencode" $ nf B.encode v+#endif , let Right v = C.parse torrentFile in bench "encode/bencoding" $ nf C.build v , bench "decode+encode/bencode" $ nf (A.bPack . fromJust . A.bRead) lazyTorrentFile+#ifdef BENCHMARK_ATTOBENCODE , bench "decode+encode/AttoBencode" $ nf (B.encode . getRight . Atto.parseOnly bValue) torrentFile+#endif , bench "decode+encode/bencoding" $ nf (C.build . getRight . C.parse) torrentFile @@ -155,8 +163,10 @@ nf (A.bPack . A.BList . L.map (A.BInt . fromIntegral)) [0..10000 :: Int] +#ifdef BENCHMARK_ATTOBENCODE , bench "list10000int/attobencode/encode" $ nf B.encode [1..20000 :: Int]+#endif , bench "list10000int/bencoding/encode" $ nf C.encode [1..20000 :: Int]
bencoding.cabal view
@@ -1,5 +1,5 @@ name: bencoding-version: 0.4.4.0+version: 0.4.5.0 license: BSD3 license-file: LICENSE author: Sam Truzjan@@ -10,7 +10,7 @@ build-type: Simple stability: Experimental cabal-version: >= 1.10-tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.3+tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.3 homepage: https://github.com/sergv/bencoding bug-reports: https://github.com/sergv/bencoding/issues synopsis: A library for encoding and decoding of BEncode data.@@ -29,7 +29,7 @@ type: git location: https://github.com/sergv/bencoding.git branch: master- tag: v0.4.4.0+ tag: v0.4.5.0 flag dev description:@@ -39,6 +39,14 @@ manual: True +flag benchmark-atto-bencode+ description:+ Compare performance of this package against AttoBencode in benchmarks+ default:+ False+ manual:+ True+ library default-language: Haskell2010 hs-source-dirs: src@@ -132,7 +140,11 @@ , bencoding , bencode >= 0.5- , AttoBencode >= 0.2++ if flag(benchmark-atto-bencode)+ build-depends: AttoBencode >= 0.2+ cpp-options: -DBENCHMARK_ATTOBENCODE+ ghc-options: -O2 -Wall if flag(dev)