Skip to content

Commit

Permalink
Initial benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
adinapoli committed Dec 26, 2016
1 parent 006bfab commit 0079d55
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
23 changes: 23 additions & 0 deletions bench/Bench.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{-# LANGUAGE OverloadedStrings #-}
module Main where

import Criterion.Main
import Crypto.RNCryptor.Types
import Crypto.RNCryptor.V3.Encrypt
import Data.ByteString as B

encryptBench :: ByteString -> ByteString
encryptBench input =
let eSalt = B.pack [0,1,2,3,4,5,6,7]
hSalt = B.pack [1,2,3,4,5,6,7,8]
iv = B.pack [2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1]
header = newRNCryptorHeaderFrom eSalt hSalt iv
ctx = newRNCryptorContext "password" header
in encrypt ctx input

main :: IO ()
main = defaultMain [
bgroup "encryption" [ bench "simple encryption" $ nf encryptBench "bench"
, bench "long encryption" $ nf encryptBench (B.pack $ Prelude.replicate 1000000 0x0)
]
]
13 changes: 13 additions & 0 deletions rncryptor.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,16 @@ executable rncryptor-encrypt
Haskell2010
ghc-options:
-funbox-strict-fields

benchmark store-bench
type: exitcode-stdio-1.0
main-is: Bench.hs
hs-source-dirs:
bench
ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -O2 -threaded -rtsopts -with-rtsopts=-N1 -with-rtsopts=-s -with-rtsopts=-qg
build-depends:
base >=4.7 && <5
, bytestring >= 0.10.4.0
, criterion
, rncryptor
default-language: Haskell2010

0 comments on commit 0079d55

Please sign in to comment.