mirror of
https://github.com/btcsuite/btcd.git
synced 2024-11-19 09:50:08 +01:00
txscript: Add benchmark for CalcWitnessSigHash
This commit is contained in:
parent
843d7607ef
commit
47806df63d
@ -50,3 +50,23 @@ func BenchmarkCalcSigHash(b *testing.B) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BenchmarkCalcWitnessSigHash benchmarks how long it takes to calculate the
|
||||||
|
// witness signature hashes for all inputs of a transaction with many inputs.
|
||||||
|
func BenchmarkCalcWitnessSigHash(b *testing.B) {
|
||||||
|
sigHashes := NewTxSigHashes(&manyInputsBenchTx)
|
||||||
|
|
||||||
|
b.ResetTimer()
|
||||||
|
b.ReportAllocs()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
for j := 0; j < len(manyInputsBenchTx.TxIn); j++ {
|
||||||
|
_, err := CalcWitnessSigHash(
|
||||||
|
prevOutScript, sigHashes, SigHashAll,
|
||||||
|
&manyInputsBenchTx, j, 5,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
b.Fatalf("failed to calc signature hash: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user