Skip to content

Commit

Permalink
benches: add rest of new jets
Browse files Browse the repository at this point in the history
All the other new jets are hashes and bit operations (random samplers)
and a few new ways of comparing gejs (which can use the sampler for the
existing equiv).
  • Loading branch information
apoelstra committed Jul 11, 2024
1 parent 234d9b2 commit f4a97ae
Showing 1 changed file with 201 additions and 0 deletions.
201 changes: 201 additions & 0 deletions jets-bench/benches/elements/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ fn jet_arrow(jet: Elements) -> (Arc<types::Final>, Arc<types::Final>) {
fn is_heavy_jet(jet: Elements) -> bool {
// Hashes
match jet {
Elements::HashToCurve |
Elements::Sha256Iv |
Elements::Sha256Block |
Elements::Sha256Ctx8Init |
Expand All @@ -106,6 +107,7 @@ fn is_heavy_jet(jet: Elements) -> bool {
Elements::Sha256Ctx8Add512 |
Elements::Sha256Ctx8AddBuffer511 |
Elements::Sha256Ctx8Finalize |
Elements::Swu |
// Jets for secp FE
Elements::FeNormalize |
Elements::FeNegate |
Expand Down Expand Up @@ -137,6 +139,8 @@ fn is_heavy_jet(jet: Elements) -> bool {
Elements::GejGeAddEx |
Elements::GejGeAdd |
Elements::GejIsInfinity |
Elements::GejEquiv |
Elements::GejGeEquiv |
Elements::GejXEquiv |
Elements::GejYIsOdd |
Elements::GejIsOnCurve |
Expand Down Expand Up @@ -333,51 +337,226 @@ fn bench(c: &mut Criterion) {
// Bit logics
(Elements::Verify, InputSampling::Random),
// low
(Elements::Low1, InputSampling::Random),
(Elements::Low8, InputSampling::Random),
(Elements::Low16, InputSampling::Random),
(Elements::Low32, InputSampling::Random),
(Elements::Low64, InputSampling::Random),
// high
(Elements::High1, InputSampling::Random),
(Elements::High8, InputSampling::Random),
(Elements::High16, InputSampling::Random),
(Elements::High32, InputSampling::Random),
(Elements::High64, InputSampling::Random),
// complement
(Elements::Complement1, InputSampling::Random),
(Elements::Complement8, InputSampling::Random),
(Elements::Complement16, InputSampling::Random),
(Elements::Complement32, InputSampling::Random),
(Elements::Complement64, InputSampling::Random),
// and
(Elements::And1, InputSampling::Random),
(Elements::And8, InputSampling::Random),
(Elements::And16, InputSampling::Random),
(Elements::And32, InputSampling::Random),
(Elements::And64, InputSampling::Random),
// or
(Elements::Or1, InputSampling::Random),
(Elements::Or8, InputSampling::Random),
(Elements::Or16, InputSampling::Random),
(Elements::Or32, InputSampling::Random),
(Elements::Or64, InputSampling::Random),
// xor
(Elements::Xor1, InputSampling::Random),
(Elements::Xor8, InputSampling::Random),
(Elements::Xor16, InputSampling::Random),
(Elements::Xor32, InputSampling::Random),
(Elements::Xor64, InputSampling::Random),
// maj
(Elements::Maj1, InputSampling::Random),
(Elements::Maj8, InputSampling::Random),
(Elements::Maj16, InputSampling::Random),
(Elements::Maj32, InputSampling::Random),
(Elements::Maj64, InputSampling::Random),
// xor xor
(Elements::XorXor1, InputSampling::Random),
(Elements::XorXor8, InputSampling::Random),
(Elements::XorXor16, InputSampling::Random),
(Elements::XorXor32, InputSampling::Random),
(Elements::XorXor64, InputSampling::Random),
// ch
(Elements::Ch1, InputSampling::Random),
(Elements::Ch8, InputSampling::Random),
(Elements::Ch16, InputSampling::Random),
(Elements::Ch32, InputSampling::Random),
(Elements::Ch64, InputSampling::Random),
// left shift
(Elements::LeftShift8, InputSampling::Random),
(Elements::LeftShift16, InputSampling::Random),
(Elements::LeftShift32, InputSampling::Random),
(Elements::LeftShift64, InputSampling::Random),
(Elements::LeftShiftWith8, InputSampling::Random),
(Elements::LeftShiftWith16, InputSampling::Random),
(Elements::LeftShiftWith32, InputSampling::Random),
(Elements::LeftShiftWith64, InputSampling::Random),
// right shift
(Elements::RightShift8, InputSampling::Random),
(Elements::RightShift16, InputSampling::Random),
(Elements::RightShift32, InputSampling::Random),
(Elements::RightShift64, InputSampling::Random),
(Elements::RightShiftWith8, InputSampling::Random),
(Elements::RightShiftWith16, InputSampling::Random),
(Elements::RightShiftWith32, InputSampling::Random),
(Elements::RightShiftWith64, InputSampling::Random),
// full left shift
(Elements::FullLeftShift8_1, InputSampling::Random),
(Elements::FullLeftShift8_2, InputSampling::Random),
(Elements::FullLeftShift8_4, InputSampling::Random),
(Elements::FullLeftShift16_1, InputSampling::Random),
(Elements::FullLeftShift16_2, InputSampling::Random),
(Elements::FullLeftShift16_4, InputSampling::Random),
(Elements::FullLeftShift16_8, InputSampling::Random),
(Elements::FullLeftShift32_1, InputSampling::Random),
(Elements::FullLeftShift32_2, InputSampling::Random),
(Elements::FullLeftShift32_4, InputSampling::Random),
(Elements::FullLeftShift32_8, InputSampling::Random),
(Elements::FullLeftShift32_16, InputSampling::Random),
(Elements::FullLeftShift64_1, InputSampling::Random),
(Elements::FullLeftShift64_2, InputSampling::Random),
(Elements::FullLeftShift64_4, InputSampling::Random),
(Elements::FullLeftShift64_8, InputSampling::Random),
(Elements::FullLeftShift64_16, InputSampling::Random),
(Elements::FullLeftShift64_32, InputSampling::Random),
// full right shift
(Elements::FullRightShift8_1, InputSampling::Random),
(Elements::FullRightShift8_2, InputSampling::Random),
(Elements::FullRightShift8_4, InputSampling::Random),
(Elements::FullRightShift16_1, InputSampling::Random),
(Elements::FullRightShift16_2, InputSampling::Random),
(Elements::FullRightShift16_4, InputSampling::Random),
(Elements::FullRightShift16_8, InputSampling::Random),
(Elements::FullRightShift32_1, InputSampling::Random),
(Elements::FullRightShift32_2, InputSampling::Random),
(Elements::FullRightShift32_4, InputSampling::Random),
(Elements::FullRightShift32_8, InputSampling::Random),
(Elements::FullRightShift32_16, InputSampling::Random),
(Elements::FullRightShift64_1, InputSampling::Random),
(Elements::FullRightShift64_2, InputSampling::Random),
(Elements::FullRightShift64_4, InputSampling::Random),
(Elements::FullRightShift64_8, InputSampling::Random),
(Elements::FullRightShift64_16, InputSampling::Random),
(Elements::FullRightShift64_32, InputSampling::Random),
// left rotate
(Elements::LeftRotate8, InputSampling::Random),
(Elements::LeftRotate16, InputSampling::Random),
(Elements::LeftRotate32, InputSampling::Random),
(Elements::LeftRotate64, InputSampling::Random),
// right rotate
(Elements::RightRotate8, InputSampling::Random),
(Elements::RightRotate16, InputSampling::Random),
(Elements::RightRotate32, InputSampling::Random),
(Elements::RightRotate64, InputSampling::Random),
// left extend
(Elements::LeftExtend1_8, InputSampling::Random),
(Elements::LeftExtend1_16, InputSampling::Random),
(Elements::LeftExtend1_32, InputSampling::Random),
(Elements::LeftExtend1_64, InputSampling::Random),
(Elements::LeftExtend8_16, InputSampling::Random),
(Elements::LeftExtend8_32, InputSampling::Random),
(Elements::LeftExtend8_64, InputSampling::Random),
(Elements::LeftExtend16_32, InputSampling::Random),
(Elements::LeftExtend16_64, InputSampling::Random),
(Elements::LeftExtend32_64, InputSampling::Random),
// right extend
// no right-extend for 1-bit values
(Elements::RightExtend8_16, InputSampling::Random),
(Elements::RightExtend8_32, InputSampling::Random),
(Elements::RightExtend8_64, InputSampling::Random),
(Elements::RightExtend16_32, InputSampling::Random),
(Elements::RightExtend16_64, InputSampling::Random),
(Elements::RightExtend32_64, InputSampling::Random),
// left pad
(Elements::LeftPadLow1_8, InputSampling::Random),
(Elements::LeftPadLow1_16, InputSampling::Random),
(Elements::LeftPadLow1_32, InputSampling::Random),
(Elements::LeftPadLow1_64, InputSampling::Random),
(Elements::LeftPadLow8_16, InputSampling::Random),
(Elements::LeftPadLow8_32, InputSampling::Random),
(Elements::LeftPadLow8_64, InputSampling::Random),
(Elements::LeftPadLow16_32, InputSampling::Random),
(Elements::LeftPadLow16_64, InputSampling::Random),
(Elements::LeftPadLow32_64, InputSampling::Random),
(Elements::LeftPadHigh1_8, InputSampling::Random),
(Elements::LeftPadHigh1_16, InputSampling::Random),
(Elements::LeftPadHigh1_32, InputSampling::Random),
(Elements::LeftPadHigh1_64, InputSampling::Random),
(Elements::LeftPadHigh8_16, InputSampling::Random),
(Elements::LeftPadHigh8_32, InputSampling::Random),
(Elements::LeftPadHigh8_64, InputSampling::Random),
(Elements::LeftPadHigh16_32, InputSampling::Random),
(Elements::LeftPadHigh16_64, InputSampling::Random),
(Elements::LeftPadHigh32_64, InputSampling::Random),
// right pad
(Elements::RightPadLow1_8, InputSampling::Random),
(Elements::RightPadLow1_16, InputSampling::Random),
(Elements::RightPadLow1_32, InputSampling::Random),
(Elements::RightPadLow1_64, InputSampling::Random),
(Elements::RightPadLow8_16, InputSampling::Random),
(Elements::RightPadLow8_32, InputSampling::Random),
(Elements::RightPadLow8_64, InputSampling::Random),
(Elements::RightPadLow16_32, InputSampling::Random),
(Elements::RightPadLow16_64, InputSampling::Random),
(Elements::RightPadLow32_64, InputSampling::Random),
(Elements::RightPadHigh1_8, InputSampling::Random),
(Elements::RightPadHigh1_16, InputSampling::Random),
(Elements::RightPadHigh1_32, InputSampling::Random),
(Elements::RightPadHigh1_64, InputSampling::Random),
(Elements::RightPadHigh8_16, InputSampling::Random),
(Elements::RightPadHigh8_32, InputSampling::Random),
(Elements::RightPadHigh8_64, InputSampling::Random),
(Elements::RightPadHigh16_32, InputSampling::Random),
(Elements::RightPadHigh16_64, InputSampling::Random),
(Elements::RightPadHigh32_64, InputSampling::Random),
// leftmost
(Elements::Leftmost8_1, InputSampling::Random),
(Elements::Leftmost8_2, InputSampling::Random),
(Elements::Leftmost8_4, InputSampling::Random),
(Elements::Leftmost16_1, InputSampling::Random),
(Elements::Leftmost16_2, InputSampling::Random),
(Elements::Leftmost16_4, InputSampling::Random),
(Elements::Leftmost16_8, InputSampling::Random),
(Elements::Leftmost32_1, InputSampling::Random),
(Elements::Leftmost32_2, InputSampling::Random),
(Elements::Leftmost32_4, InputSampling::Random),
(Elements::Leftmost32_8, InputSampling::Random),
(Elements::Leftmost32_16, InputSampling::Random),
(Elements::Leftmost64_1, InputSampling::Random),
(Elements::Leftmost64_2, InputSampling::Random),
(Elements::Leftmost64_4, InputSampling::Random),
(Elements::Leftmost64_8, InputSampling::Random),
(Elements::Leftmost64_16, InputSampling::Random),
(Elements::Leftmost64_32, InputSampling::Random),
// rightmost
(Elements::Rightmost8_1, InputSampling::Random),
(Elements::Rightmost8_2, InputSampling::Random),
(Elements::Rightmost8_4, InputSampling::Random),
(Elements::Rightmost16_1, InputSampling::Random),
(Elements::Rightmost16_2, InputSampling::Random),
(Elements::Rightmost16_4, InputSampling::Random),
(Elements::Rightmost16_8, InputSampling::Random),
(Elements::Rightmost32_1, InputSampling::Random),
(Elements::Rightmost32_2, InputSampling::Random),
(Elements::Rightmost32_4, InputSampling::Random),
(Elements::Rightmost32_8, InputSampling::Random),
(Elements::Rightmost32_16, InputSampling::Random),
(Elements::Rightmost64_1, InputSampling::Random),
(Elements::Rightmost64_2, InputSampling::Random),
(Elements::Rightmost64_4, InputSampling::Random),
(Elements::Rightmost64_8, InputSampling::Random),
(Elements::Rightmost64_16, InputSampling::Random),
(Elements::Rightmost64_32, InputSampling::Random),
// some
(Elements::Some1, InputSampling::Random),
(Elements::Some8, InputSampling::Random),
(Elements::Some16, InputSampling::Random),
(Elements::Some32, InputSampling::Random),
Expand All @@ -398,6 +577,7 @@ fn bench(c: &mut Criterion) {
// and we don't care as much here. Also, likely for
// x86_64, upto eq64 it would be one instruction.
// we do test eq_256 separately.
(Elements::Eq1, InputSampling::Random),
(Elements::Eq8, InputSampling::Random),
(Elements::Eq16, InputSampling::Random),
(Elements::Eq32, InputSampling::Random),
Expand Down Expand Up @@ -429,6 +609,11 @@ fn bench(c: &mut Criterion) {
(Elements::Subtract16, InputSampling::Random),
(Elements::Subtract32, InputSampling::Random),
(Elements::Subtract64, InputSampling::Random),
// full subtract
(Elements::FullSubtract8, InputSampling::Random),
(Elements::FullSubtract16, InputSampling::Random),
(Elements::FullSubtract32, InputSampling::Random),
(Elements::FullSubtract64, InputSampling::Random),
// negate
(Elements::Negate8, InputSampling::Random),
(Elements::Negate16, InputSampling::Random),
Expand All @@ -439,6 +624,11 @@ fn bench(c: &mut Criterion) {
(Elements::FullDecrement16, InputSampling::Random),
(Elements::FullDecrement32, InputSampling::Random),
(Elements::FullDecrement64, InputSampling::Random),
// decrement
(Elements::Decrement8, InputSampling::Random),
(Elements::Decrement16, InputSampling::Random),
(Elements::Decrement32, InputSampling::Random),
(Elements::Decrement64, InputSampling::Random),
// multiply
(Elements::Multiply8, InputSampling::Random),
(Elements::Multiply16, InputSampling::Random),
Expand Down Expand Up @@ -489,6 +679,7 @@ fn bench(c: &mut Criterion) {
(Elements::DivMod16, InputSampling::Random),
(Elements::DivMod32, InputSampling::Random),
(Elements::DivMod64, InputSampling::Random),
(Elements::DivMod128_64, InputSampling::Random),
// divide
(Elements::Divide8, InputSampling::Random),
(Elements::Divide16, InputSampling::Random),
Expand All @@ -506,6 +697,7 @@ fn bench(c: &mut Criterion) {
(Elements::Divides64, InputSampling::Random),

// Hashes
(Elements::HashToCurve, InputSampling::Random),
(Elements::Sha256Iv, InputSampling::Random),
(Elements::Sha256Block, InputSampling::Random),
(Elements::Sha256Ctx8Init, InputSampling::Random),
Expand All @@ -521,6 +713,7 @@ fn bench(c: &mut Criterion) {
(Elements::Sha256Ctx8Add512, InputSampling::Custom(Arc::new(|| ctx8_add_n(512)))),
(Elements::Sha256Ctx8AddBuffer511, InputSampling::Custom(Arc::new(|| ctx8_add_n(511)))),
(Elements::Sha256Ctx8Finalize, InputSampling::Custom(Arc::new(|| SimplicityCtx8::with_len(511).value()))),
(Elements::Swu, InputSampling::Random),
// Jets for secp FE
(Elements::FeNormalize, InputSampling::Custom(Arc::new(|| SimplicityFe::sample().value()))),
(Elements::FeNegate, InputSampling::Custom(Arc::new(|| SimplicityFe::sample().value()))),
Expand Down Expand Up @@ -552,6 +745,8 @@ fn bench(c: &mut Criterion) {
(Elements::GejGeAddEx, InputSampling::Custom(Arc::new(gej_ge_pair))),
(Elements::GejGeAdd, InputSampling::Custom(Arc::new(gej_ge_pair))),
(Elements::GejIsInfinity, InputSampling::Custom(Arc::new(|| SimplicityGej{ ge: SimplicityGe::sample(), z: SimplicityFe::zero() }.value()))),
(Elements::GejEquiv, InputSampling::Custom(Arc::new(fe_gej_pair))),
(Elements::GejGeEquiv, InputSampling::Custom(Arc::new(fe_gej_pair))),
(Elements::GejXEquiv, InputSampling::Custom(Arc::new(fe_gej_pair))),
(Elements::GejYIsOdd, InputSampling::Custom(Arc::new(|| SimplicityGej::sample().value()))),
(Elements::GejIsOnCurve, InputSampling::Custom(Arc::new(|| SimplicityGej::sample().value()))),
Expand Down Expand Up @@ -632,6 +827,7 @@ fn bench(c: &mut Criterion) {
//
// ------------------------------------
// Jets with no environment required. But no custom sampling
(Elements::LbtcAsset, ElementsBenchEnvType::None),
(Elements::BuildTapleafSimplicity, ElementsBenchEnvType::None),
(Elements::BuildTapbranch, ElementsBenchEnvType::None),
// ------------------------------------
Expand Down Expand Up @@ -661,6 +857,7 @@ fn bench(c: &mut Criterion) {
(Elements::NumInputs, ElementsBenchEnvType::Random),
(Elements::NumOutputs, ElementsBenchEnvType::Random),
(Elements::LockTime, ElementsBenchEnvType::Random),
(Elements::TransactionId, ElementsBenchEnvType::Random),
(Elements::TotalFee, ElementsBenchEnvType::AllFeeOutputs),
// // -----------------------------------------
// Current Input
Expand Down Expand Up @@ -813,6 +1010,7 @@ fn bench(c: &mut Criterion) {
(Elements::OutputAsset, Index::Output, ElementsBenchEnvType::Random),
(Elements::OutputAmount, Index::Output, ElementsBenchEnvType::Random),
(Elements::OutputNonce, Index::Output, ElementsBenchEnvType::Random),
(Elements::OutputHash, Index::Output, ElementsBenchEnvType::Random),
(Elements::OutputScriptHash, Index::Output, ElementsBenchEnvType::Random),
(Elements::OutputNullDatum, Index::Output, ElementsBenchEnvType::Random), // I Don't know what this is, and how to test this, presumably related to how pegouts work
(Elements::OutputSurjectionProof, Index::Output, ElementsBenchEnvType::Random),
Expand All @@ -823,8 +1021,10 @@ fn bench(c: &mut Criterion) {
(Elements::InputPrevOutpoint, Index::Input, ElementsBenchEnvType::Random),
(Elements::InputAsset, Index::Input, ElementsBenchEnvType::Random),
(Elements::InputAmount, Index::Input, ElementsBenchEnvType::Random),
(Elements::InputHash, Index::Input, ElementsBenchEnvType::Random),
(Elements::InputScriptHash, Index::Input, ElementsBenchEnvType::Random),
(Elements::InputSequence, Index::Input, ElementsBenchEnvType::Random),
(Elements::InputUtxoHash, Index::Input, ElementsBenchEnvType::Random),
(Elements::InputAnnexHash, Index::InputIdx0, ElementsBenchEnvType::Annex),
(Elements::InputScriptSigHash, Index::Input, ElementsBenchEnvType::Random),
(Elements::ReissuanceBlinding, Index::InputIdx0, ElementsBenchEnvType::Issuance),
Expand All @@ -834,6 +1034,7 @@ fn bench(c: &mut Criterion) {
(Elements::IssuanceTokenAmount, Index::InputIdx0, ElementsBenchEnvType::Issuance),
(Elements::IssuanceAssetProof, Index::InputIdx0, ElementsBenchEnvType::Issuance),
(Elements::IssuanceTokenProof, Index::InputIdx0, ElementsBenchEnvType::Issuance),
(Elements::IssuanceHash, Index::InputIdx0, ElementsBenchEnvType::Issuance),
(Elements::Tappath, Index::MarkleBranchIndex, ElementsBenchEnvType::Random),
];

Expand Down

0 comments on commit f4a97ae

Please sign in to comment.