mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 15:11:09 +02:00
keychain: add basic benchmark for privkey derivation
This commit is contained in:
41
keychain/bench_test.go
Normal file
41
keychain/bench_test.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package keychain
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/btcsuite/btcd/btcec"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func BenchmarkDerivePrivKey(t *testing.B) {
|
||||||
|
cleanUp, wallet, err := createTestBtcWallet(
|
||||||
|
CoinTypeBitcoin,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unable to create wallet: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
keyRing := NewBtcWalletKeyRing(wallet, CoinTypeBitcoin)
|
||||||
|
|
||||||
|
defer cleanUp()
|
||||||
|
|
||||||
|
var (
|
||||||
|
privKey *btcec.PrivateKey
|
||||||
|
)
|
||||||
|
|
||||||
|
keyDesc := KeyDescriptor{
|
||||||
|
KeyLocator: KeyLocator{
|
||||||
|
Family: KeyFamilyMultiSig,
|
||||||
|
Index: 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
t.ReportAllocs()
|
||||||
|
t.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < t.N; i++ {
|
||||||
|
privKey, err = keyRing.DerivePrivKey(keyDesc)
|
||||||
|
}
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, privKey)
|
||||||
|
}
|
Reference in New Issue
Block a user