Permalink
Browse files

Add benchmarks for the siphash package

  • Loading branch information...
bos committed Sep 30, 2012
1 parent 831a18f commit 0f42ab89432ded213d7aae068546596ae9897a58
Showing with 10 additions and 0 deletions.
  1. +9 −0 benchmarks/Benchmarks.hs
  2. +1 −0 benchmarks/hashable-benchmarks.cabal
View
@@ -10,6 +10,7 @@ import Foreign.ForeignPtr
import GHC.Exts
import GHC.ST (ST(..))
import qualified Data.ByteString as B
+import qualified Crypto.MAC.SipHash as HS
-- Benchmark English words (5 and 8), base64 encoded integers (11),
-- SHA1 hashes as hex (40), and large blobs (1 Mb).
@@ -37,6 +38,7 @@ main = do
!bs1Mb = B.pack . map fromIntegral $ [0..999999::Int]
let sipHash = hashByteString 2 4 0x4a7330fae70f52e8 0x919ea5953a9a1ec9
+ hsSipHash = HS.hash (HS.SipKey 0x4a7330fae70f52e8 0x919ea5953a9a1ec9)
withForeignPtr fp5 $ \ p5 ->
withForeignPtr fp8 $ \ p8 ->
@@ -74,6 +76,13 @@ main = do
, bench "40" $ whnf sipHash bs40
, bench "2^20" $ whnf sipHash bs1Mb
]
+ , bgroup "pkgSipHash"
+ [ bench "5" $ whnf hsSipHash bs5
+ , bench "8" $ whnf hsSipHash bs8
+ , bench "11" $ whnf hsSipHash bs11
+ , bench "40" $ whnf hsSipHash bs40
+ , bench "2^20" $ whnf hsSipHash bs1Mb
+ ]
]
data ByteArray = BA { unBA :: !ByteArray# }
@@ -17,4 +17,5 @@ executable hashable-benchmarks
bytestring,
criterion,
ghc-prim,
+ siphash,
text

0 comments on commit 0f42ab8

Please sign in to comment.