commit 2d2f1949531f6a688a5cc021cabce4e086f5de02
parent 8c974a227235135075ae1435dac6d6f3c6e745f1
Author: Jared Tobin <jared@jtobin.io>
Date: Tue, 12 Nov 2024 12:22:08 +0400
bench: suite
Diffstat:
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/bench/Main.hs b/bench/Main.hs
@@ -1,5 +1,32 @@
+{-# LANGUAGE OverloadedStrings #-}
module Main where
+import Criterion.Main
+import qualified Crypto.Hash.RIPEMD160 as RIPEMD160
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Lazy as BL
+
main :: IO ()
-main = pure ()
+main = defaultMain [
+ suite
+ ]
+
+suite :: Benchmark
+suite = env setup $ \ ~(bs, bl) ->
+ bgroup "ppad-ripemd160" [
+ bgroup "RIPEMD160 (32B input)" [
+ bench "hash" $ whnf RIPEMD160.hash bs
+ , bench "hash_lazy" $ whnf RIPEMD160.hash_lazy bl
+ ]
+ , bgroup "HMAC-RIPEMD160 (32B input)" [
+ bench "hmac" $ whnf (RIPEMD160.hmac "key") bs
+ , bench "hmac_lazy" $ whnf (RIPEMD160.hmac_lazy "key") bl
+ ]
+ ]
+ where
+ setup = do
+ let bs_32B = BS.replicate 32 0
+ bl_32B = BL.fromStrict bs_32B
+ pure (bs_32B, bl_32B)
+