Skip to content

Commit d806205

Browse files
committed
benchmark-blake2: use more of the cryptonite API
1 parent 73ff535 commit d806205

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

benchmark-blake2/Main.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ import Data.List (foldl')
88

99
import "criterion" Criterion.Main
1010
import qualified "memory" Data.ByteArray as B
11+
import qualified "memory" Data.ByteArray.Encoding as E
1112
import qualified "base16-bytestring" Data.ByteString.Base16 as B16
1213
import qualified "bytestring" Data.ByteString as BS
14+
import qualified "bytestring" Data.ByteString.Char8 (pack)
1315
import qualified "blake2" Crypto.Hash.BLAKE2.BLAKE2b as Original
1416
import qualified "blake2-patched" Crypto.Hash.BLAKE2.BLAKE2b as Patched
1517
import qualified "cryptonite" Crypto.Hash as Cryptonite
1618

1719
cryptoniteHash :: BS.ByteString -> BS.ByteString
18-
cryptoniteHash = B16.encode . B.convert . Cryptonite.hashWith Cryptonite.Blake2b_512
20+
cryptoniteHash = (B.convert :: BS.ByteString -> BS.ByteString) . E.convertToBase E.Base16 . Cryptonite.hashWith Cryptonite.Blake2b_512
1921
{-# INLINE cryptoniteHash #-}
2022

2123
originalHash :: BS.ByteString -> BS.ByteString
@@ -37,7 +39,7 @@ main = defaultMain
3739

3840
hashes :: IO [BS.ByteString]
3941
hashes = let
40-
ns = map (cryptoniteHash . pack . show) [1..100000]
42+
ns = map (patchedHash . pack . show) [1..100000]
4143
in length ns `seq` pure ns
4244

4345
bencher :: (BS.ByteString -> BS.ByteString) -> IO Bool

0 commit comments

Comments
 (0)