-
Notifications
You must be signed in to change notification settings - Fork 12
/
stress_benchmark_test.go
45 lines (39 loc) · 1.54 KB
/
stress_benchmark_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package acceptance
import (
"context"
"fmt"
"github.com/orbs-network/orbs-network-go/config"
"github.com/orbs-network/orbs-network-go/test/rand"
"testing"
)
func BenchmarkHappyFlow1k(b *testing.B) {
numTransactions := 1000
rnd := rand.NewControlledRand(b)
NewHarness().Start(b, func(t testing.TB, ctx context.Context, network *Network) {
for n := 0; n < b.N; n++ {
b.StartTimer()
transferDuration, waitDuration := sendTransfersAndAssertTotalBalance(ctx, network, t, numTransactions, rnd)
b.StopTimer()
fmt.Println("finished sending ", numTransactions, "transactions in", transferDuration)
fmt.Println("finished waiting for", numTransactions, "transactions in", waitDuration)
}
})
}
func BenchmarkHappyFlow1kWithOverrides(b *testing.B) {
numTransactions := 1000
rnd := rand.NewControlledRand(b)
NewHarness().
WithConfigOverride(
config.NodeConfigKeyValue{Key: config.CONSENSUS_CONTEXT_MAXIMUM_TRANSACTIONS_IN_BLOCK, Value: config.NodeConfigValue{Uint32Value: 70}},
config.NodeConfigKeyValue{Key: config.TRANSACTION_POOL_PROPAGATION_BATCH_SIZE, Value: config.NodeConfigValue{Uint32Value: 100}},
).
Start(b, func(t testing.TB, ctx context.Context, network *Network) {
for n := 0; n < b.N; n++ {
b.StartTimer()
transferDuration, waitDuration := sendTransfersAndAssertTotalBalance(ctx, network, t, numTransactions, rnd)
b.StopTimer()
fmt.Println("finished sending ", numTransactions, "transactions in", transferDuration)
fmt.Println("finished waiting for", numTransactions, "transactions in", waitDuration)
}
})
}