[commit: packages/binary] master: Use monoid in Put benchmark. (1ecfd22)

git at git.haskell.org git at git.haskell.org
Tue Apr 19 20:30:52 UTC 2016


Repository : ssh://git@git.haskell.org/binary

On branch  : master
Link       : http://git.haskell.org/packages/binary.git/commitdiff/1ecfd2272e96ca58a4f7f672b5ff3a7ee9f0ccb0

>---------------------------------------------------------------

commit 1ecfd2272e96ca58a4f7f672b5ff3a7ee9f0ccb0
Author: Lennart Kolmodin <kolmodin at gmail.com>
Date:   Sat Apr 16 12:41:05 2016 +0200

    Use monoid in Put benchmark.


>---------------------------------------------------------------

1ecfd2272e96ca58a4f7f672b5ff3a7ee9f0ccb0
 benchmarks/Put.hs | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/benchmarks/Put.hs b/benchmarks/Put.hs
index 12b7dbf..3d482eb 100644
--- a/benchmarks/Put.hs
+++ b/benchmarks/Put.hs
@@ -45,16 +45,16 @@ main = do
       bench "small Strings" $ whnf (run . fromStrings) smallStrings,
       bench "[small String]" $ whnf (run . put) smallStrings,
 
-      bench "Word8s" $ whnf (run . fromWord8s) word8s,
+      bench "Word8s monoid put" $ whnf (run . fromWord8s) word8s,
       bench "Word8s builder" $ whnf (L.length . toLazyByteString . fromWord8sBuilder) word8s,
       bench "[Word8]" $ whnf (run . put) word8s,
-      bench "Word16s" $ whnf (run . fromWord16s) word16s,
+      bench "Word16s monoid put" $ whnf (run . fromWord16s) word16s,
       bench "Word16s builder" $ whnf (L.length . toLazyByteString . fromWord16sBuilder) word16s,
       bench "[Word16]" $ whnf (run . put) word16s,
-      bench "Word32s" $ whnf (run . fromWord32s) word32s,
+      bench "Word32s monoid put" $ whnf (run . fromWord32s) word32s,
       bench "Word32s builder" $ whnf (L.length . toLazyByteString . fromWord32sBuilder) word32s,
       bench "[Word32]" $ whnf (run . put) word32s,
-      bench "Word64s" $ whnf (run . fromWord64s) word64s,
+      bench "Word64s monoid put" $ whnf (run . fromWord64s) word64s,
       bench "Word64s builder" $ whnf (L.length . toLazyByteString . fromWord64sBuilder) word64s,
       bench "[Word64]" $ whnf (run . put) word64s
 
@@ -125,44 +125,44 @@ word64s = take 10000 $ cycle [minBound .. maxBound]
 -- Benchmarks
 
 fromIntegers :: [Integer] -> Put
-fromIntegers [] = return ()
-fromIntegers (x:xs) = put x >> fromIntegers xs
+fromIntegers [] = mempty
+fromIntegers (x:xs) = put x `mappend` fromIntegers xs
 
 fromByteStrings :: [S.ByteString] -> Put
-fromByteStrings [] = return ()
-fromByteStrings (x:xs) = put x >> fromByteStrings xs
+fromByteStrings [] = mempty
+fromByteStrings (x:xs) = put x `mappend` fromByteStrings xs
 
 fromStrings :: [String] -> Put
-fromStrings [] = return ()
-fromStrings (x:xs) = put x >> fromStrings xs
+fromStrings [] = mempty
+fromStrings (x:xs) = put x `mappend` fromStrings xs
 
 fromWord8s :: [Word8] -> Put
-fromWord8s [] = return ()
-fromWord8s (x:xs) = put x >> fromWord8s xs
+fromWord8s [] = mempty
+fromWord8s (x:xs) = put x `mappend` fromWord8s xs
 
 fromWord8sBuilder :: [Word8] -> BB.Builder
 fromWord8sBuilder [] = mempty
 fromWord8sBuilder (x:xs) = BB.word8 x `mappend` fromWord8sBuilder xs
 
 fromWord16s :: [Word16] -> Put
-fromWord16s [] = return ()
-fromWord16s (x:xs) = put x >> fromWord16s xs
+fromWord16s [] = mempty
+fromWord16s (x:xs) = put x `mappend` fromWord16s xs
 
 fromWord16sBuilder :: [Word16] -> BB.Builder
 fromWord16sBuilder [] = mempty
 fromWord16sBuilder (x:xs) = BB.word16BE x `mappend` fromWord16sBuilder xs
 
 fromWord32s :: [Word32] -> Put
-fromWord32s [] = return ()
-fromWord32s (x:xs) = put x >> fromWord32s xs
+fromWord32s [] = mempty
+fromWord32s (x:xs) = put x `mappend` fromWord32s xs
 
 fromWord32sBuilder :: [Word32] -> BB.Builder
 fromWord32sBuilder [] = mempty
 fromWord32sBuilder (x:xs) = BB.word32BE x `mappend` fromWord32sBuilder xs
 
 fromWord64s :: [Word64] -> Put
-fromWord64s [] = return ()
-fromWord64s (x:xs) = put x >> fromWord64s xs
+fromWord64s [] = mempty
+fromWord64s (x:xs) = put x `mappend` fromWord64s xs
 
 fromWord64sBuilder :: [Word64] -> BB.Builder
 fromWord64sBuilder [] = mempty
@@ -170,10 +170,10 @@ fromWord64sBuilder (x:xs) = BB.word64BE x `mappend` fromWord64sBuilder xs
 
 #ifdef GENERICS
 fromStructs :: [Struct] -> Put
-fromStructs [] = return ()
-fromStructs (x:xs) = put x >> fromStructs xs
+fromStructs [] = mempty
+fromStructs (x:xs) = put x `mappend` fromStructs xs
 
 fromStructLists :: [StructList] -> Put
-fromStructLists [] = return ()
-fromStructLists (x:xs) = put x >> fromStructLists xs
+fromStructLists [] = mempty
+fromStructLists (x:xs) = put x `mappend` fromStructLists xs
 #endif



More information about the ghc-commits mailing list