Skip to content

Commit 70b14d0

Browse files
committed
prepare for percentile usage
1 parent 5ea2434 commit 70b14d0

File tree

1 file changed

+14
-3
lines changed
  • pkg/coordinator/tasks/tx_pool_throughput_analysis

1 file changed

+14
-3
lines changed

pkg/coordinator/tasks/tx_pool_throughput_analysis/task.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"crypto/rand"
66
"encoding/json"
7+
"errors"
78
"fmt"
89
"math/big"
910
"time"
@@ -125,6 +126,7 @@ func (t *Task) Execute(ctx context.Context) error {
125126
// Create a new load target for the transaction propagation measurement
126127
loadTarget := txloadtool.NewLoadTarget(ctx, t.ctx, t.logger, t.wallet, client)
127128

129+
percentile := 0.99 // 0.95 should be enough, change in the future if needed
128130
singleMeasureDeadline := time.Now().Add(time.Duration(t.config.DurationS+60*30) * time.Second)
129131

130132
// slice of pairs: sending tps, processed TPS values
@@ -136,7 +138,7 @@ func (t *Task) Execute(ctx context.Context) error {
136138

137139
for sendingTps := t.config.StartingTPS; sendingTps <= t.config.EndingTPS; sendingTps += t.config.IncrementTPS {
138140
// measure the throughput with the current sendingTps
139-
processedTps, err := t.measureTpsWithLoad(loadTarget, sendingTps, t.config.DurationS, singleMeasureDeadline)
141+
processedTps, err := t.measureTpsWithLoad(loadTarget, sendingTps, t.config.DurationS, singleMeasureDeadline, percentile)
140142
if err != nil {
141143
t.logger.Errorf("Error during throughput measurement with sendingTps=%d, duration=%d: %v", sendingTps, t.config.DurationS, err)
142144
t.ctx.SetResult(types.TaskResultFailure)
@@ -170,7 +172,8 @@ func (t *Task) Execute(ctx context.Context) error {
170172
return nil
171173
}
172174

173-
func (t *Task) measureTpsWithLoad(loadTarget *txloadtool.LoadTarget, sendingTps, durationS int, testDeadline time.Time) (int, error) {
175+
func (t *Task) measureTpsWithLoad(loadTarget *txloadtool.LoadTarget, sendingTps, durationS int,
176+
testDeadline time.Time, percentile float64) (int, error) {
174177
t.logger.Infof("Single measure of throughput, sending TPS: %d, duration: %d secs", sendingTps, durationS)
175178

176179
// Prepare to collect transaction latencies
@@ -219,7 +222,15 @@ func (t *Task) measureTpsWithLoad(loadTarget *txloadtool.LoadTarget, sendingTps,
219222

220223
t.logger.Infof("Total transactions sent: %d", result.TotalTxs)
221224

222-
// Calculate statistics
225+
if percentile != 0.99 {
226+
// Calculate the percentile of latencies using result.LatenciesMus
227+
// Not implemented yet
228+
notImpl := errors.New("percentile selection not implemented, use 0.99")
229+
return 0, notImpl
230+
} else {
231+
t.logger.Infof("Using 0.99 percentile for latency calculation")
232+
}
233+
223234
t.logger.Infof("Last measure delay since start time: %s", result.LastMeasureDelay)
224235

225236
processedTpsF := float64(result.TotalTxs) / result.LastMeasureDelay.Seconds()

0 commit comments

Comments
 (0)