-
Notifications
You must be signed in to change notification settings - Fork 23
/
VerifyCredentialPerf.hs
54 lines (42 loc) · 1.28 KB
/
VerifyCredentialPerf.hs
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Criterion
import Criterion.Main
import Criterion.Types
import qualified Data.ByteString.Char8 as BS
import Concordium.ID.Account
import Concordium.ID.AnonymityRevoker
import Concordium.ID.IdentityProvider
import Concordium.ID.Parameters
import Concordium.Types
import Data.Serialize
-- This should match with the EXPIRY constant in generate_testdata.
maxExpiry :: TransactionTime
maxExpiry = TransactionTime maxBound
filePath :: FilePath
filePath = "testdata/testdata.bin"
type Data = (GlobalContext, IpInfo, [ArInfo], CredentialDeploymentInformationBytes)
readData :: BS.ByteString -> Either String Data
readData bs = flip runGet bs $ do
gc <- get
ipInfo <- get
arInfos <- get
l1 <- getWord32be
cdi1 <- getByteString (fromIntegral l1)
return (gc, ipInfo, arInfos, cdi1)
setup :: IO Data
setup = do
bs <- BS.readFile filePath
case readData bs of
Left err -> error err
Right d -> return d
verify :: Benchmark
verify =
env setup $ \ ~(gc, ipInfo, arInfos, cdi1) ->
bench "Verify credential success" $ nf (flip (verifyCredential gc ipInfo arInfos) (Left maxExpiry)) cdi1
main :: IO ()
main =
defaultMainWith
(defaultConfig{timeLimit = 15})
[ verify
]