aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/bench.hs
blob: e66dadd6d3c67e777816407269fb9875f499d6bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{-#LANGUAGE OverloadedStrings #-}

import Data.ByteString (ByteString)
import Criterion.Main

import Crypto.Macaroon
import Crypto.Macaroon.Internal


loc :: ByteString
loc = "http://mybank/"

ident :: ByteString
ident = "we used our secret key"

key :: ByteString
key = "this is our super secret key; only we should know it"

cav :: ByteString
cav = "test = caveat"


{-#INLINE benchCreate#-}
benchCreate :: (Key, Key, Location) -> Macaroon
benchCreate (secret, ident, loc) = create secret ident loc

{-#INLINE benchMint #-}
benchMint :: ((Key, Key, Location), ByteString) -> Macaroon
benchMint (ms,c) = addFirstPartyCaveat c (benchCreate ms)

main = defaultMain [
    bgroup "Crypto.Macaroon" [ bench "create"  $ nf benchCreate (key,ident,loc)
                             , bench "mint"  $ nf benchMint ((key,ident,loc),cav)
                             ]
    ]