Main.hs (3388B)
1 module Main where 2 3 import Criterion.Main 4 import Fixtures 5 import Lightning.Protocol.BOLT3 6 7 main :: IO () 8 main = do 9 fx <- fixtures 10 let (next_idx, next_secret) = fx_store_next fx 11 keys = ck fx 12 defaultMain [ 13 bgroup "keys" [ 14 bench "derive_per_commitment_point" $ 15 nf derive_per_commitment_point (fx_secret fx) 16 , bench "derive_per_commitment_point'" $ 17 nf (derive_per_commitment_point' tex) (fx_secret fx) 18 , bench "derive_pubkey" $ 19 nf (derive_pubkey (fx_basepoint fx)) (fx_pcp fx) 20 , bench "derive_revocationpubkey" $ 21 nf (derive_revocationpubkey (fx_rbp fx)) (fx_pcp fx) 22 , bench "derive_commitment_keys" $ 23 nf (derive_commitment_keys (fx_local_bps fx) (fx_local_fund fx) 24 (fx_remote_bps fx) (fx_remote_fund fx)) (fx_pcp fx) 25 , bench "derive_commitment_keys'" $ 26 nf (derive_commitment_keys' tex (fx_local_bps fx) (fx_local_fund fx) 27 (fx_remote_bps fx) (fx_remote_fund fx)) (fx_pcp fx) 28 , bench "derive_privkey" $ 29 nf (derive_privkey (fx_seckey fx)) (fx_pcp fx) 30 , bench "derive_revocationprivkey" $ 31 nf (derive_revocationprivkey (fx_seckey fx)) (fx_secret fx) 32 ] 33 , bgroup "secrets" [ 34 bench "generate_from_seed (index 2^48 - 1)" $ 35 nf (generate_from_seed (fx_seed fx)) (fx_store_oldest fx) 36 , bench "insert_secret (14 lower buckets)" $ 37 nf (insert_secret next_secret next_idx) (fx_store fx) 38 , bench "derive_old_secret (index 2^48 - 1)" $ 39 nf (derive_old_secret (fx_store_oldest fx)) (fx_store fx) 40 , bench "secret_store . un_secret_store" $ 41 nf (secret_store . un_secret_store) (fx_store fx) 42 ] 43 , bgroup "scripts" [ 44 bench "funding_script" $ 45 nf (funding_script (fx_local_fund fx)) (fx_remote_fund fx) 46 , bench "to_local_script" $ 47 nf (to_local_script (ck_revocation_pubkey keys) (ToSelfDelay 144)) 48 (ck_local_delayed keys) 49 , bench "offered_htlc_script" $ 50 nf (offered_htlc_script (ck_revocation_pubkey keys) 51 (ck_remote_htlc keys) (ck_local_htlc keys) (hash fx)) 52 Anchors 53 , bench "received_htlc_script" $ 54 nf (received_htlc_script (ck_revocation_pubkey keys) 55 (ck_remote_htlc keys) (ck_local_htlc keys) (hash fx) 56 (CltvExpiry 500)) 57 Anchors 58 ] 59 , bgroup "transactions" [ 60 bench "build_commitment_tx (no htlcs)" $ 61 nf build_commitment_tx (fx_ctx_simple fx) 62 , bench "build_commitment_tx (5 htlcs)" $ 63 nf build_commitment_tx (fx_ctx_htlcs fx) 64 , bench "build_commitment_tx (5 htlcs, anchors)" $ 65 nf build_commitment_tx (fx_ctx_anchors fx) 66 , bench "encode_commitment_tx (5 htlcs)" $ 67 nf encode_commitment_tx (fx_commit fx) 68 , bench "build_htlc_tx" $ 69 nf build_htlc_tx (fx_htlc_ctx fx) 70 , bench "encode_htlc_tx" $ 71 nf encode_htlc_tx (fx_htlc_tx fx) 72 , bench "build_closing_tx" $ 73 nf build_closing_tx (fx_closing fx) 74 , bench "build_legacy_closing_tx" $ 75 nf build_legacy_closing_tx (fx_legacy fx) 76 , bench "encode_closing_tx" $ 77 nf encode_closing_tx (fx_closing_tx fx) 78 ] 79 ] 80 where 81 ck = cc_keys . fx_ctx_simple 82 hash = htlc_payment_hash . hc_htlc . fx_htlc_ctx