Skip to content
Snippets Groups Projects
Commit 4683c8a9 authored by Hans Moog's avatar Hans Moog
Browse files

Feat: benchmark: 50000 data TPS (complete parsing + validating)

parent 2f702a17
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,42 @@ import ( ...@@ -22,6 +22,42 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func BenchmarkVerifyDataTransactions(b *testing.B) {
transactions := make([][]byte, b.N)
for i := 0; i < b.N; i++ {
tx := transaction.New(transaction.EmptyId, transaction.EmptyId, identity.Generate(), data.New([]byte("some data")))
if marshaledTransaction, err := tx.MarshalBinary(); err != nil {
b.Error(err)
} else {
transactions[i] = marshaledTransaction
}
}
var wg sync.WaitGroup
b.ResetTimer()
for i := 0; i < b.N; i++ {
wg.Add(1)
currentIndex := i
if err := ants.Submit(func() {
if tx, err := transaction.FromBytes(transactions[currentIndex]); err != nil {
b.Error(err)
} else {
tx.VerifySignature()
}
wg.Done()
}); err != nil {
b.Error(err)
}
}
wg.Wait()
}
func BenchmarkVerifyValueTransactions(b *testing.B) { func BenchmarkVerifyValueTransactions(b *testing.B) {
keyPairOfSourceAddress := ed25119.GenerateKeyPair() keyPairOfSourceAddress := ed25119.GenerateKeyPair()
keyPairOfTargetAddress := ed25119.GenerateKeyPair() keyPairOfTargetAddress := ed25119.GenerateKeyPair()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment