Skip to content

Commit

Permalink
Extend the load report tool to include transactions' hashes (tendermi…
Browse files Browse the repository at this point in the history
…nt#9509)

* Add transaction hash to raw data

* Add hash in formatted output

* Cosmetic
  • Loading branch information
sergio-mena authored Oct 5, 2022
1 parent b1dc5a6 commit cdd3479
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions test/loadtime/cmd/report/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ func toCSVRecords(rs []report.Report) [][]string {
}
res := make([][]string, total+1)

res[0] = []string{"experiment_id", "duration_ns", "block_time", "connections", "rate", "size"}
res[0] = []string{"experiment_id", "block_time", "duration_ns", "tx_hash", "connections", "rate", "size"}
offset := 1
for _, r := range rs {
idStr := r.ID.String()
connStr := strconv.FormatInt(int64(r.Connections), 10)
rateStr := strconv.FormatInt(int64(r.Rate), 10)
sizeStr := strconv.FormatInt(int64(r.Size), 10)
for i, v := range r.All {
res[offset+i] = []string{idStr, strconv.FormatInt(int64(v.Duration), 10), strconv.FormatInt(v.BlockTime.UnixNano(), 10), connStr, rateStr, sizeStr}
res[offset+i] = []string{idStr, strconv.FormatInt(v.BlockTime.UnixNano(), 10), strconv.FormatInt(int64(v.Duration), 10), fmt.Sprintf("%X", v.Hash), connStr, rateStr, sizeStr}
}
offset += len(r.All)
}
Expand Down
11 changes: 7 additions & 4 deletions test/loadtime/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type BlockStore interface {
type DataPoint struct {
Duration time.Duration
BlockTime time.Time
Hash []byte
}

// Report contains the data calculated from reading the timestamped transactions
Expand Down Expand Up @@ -68,7 +69,7 @@ func (rs *Reports) ErrorCount() int {
return rs.errorCount
}

func (rs *Reports) addDataPoint(id uuid.UUID, l time.Duration, bt time.Time, conns, rate, size uint64) {
func (rs *Reports) addDataPoint(id uuid.UUID, l time.Duration, bt time.Time, hash []byte, conns, rate, size uint64) {
r, ok := rs.s[id]
if !ok {
r = Report{
Expand All @@ -81,7 +82,7 @@ func (rs *Reports) addDataPoint(id uuid.UUID, l time.Duration, bt time.Time, con
}
rs.s[id] = r
}
r.All = append(r.All, DataPoint{Duration: l, BlockTime: bt})
r.All = append(r.All, DataPoint{Duration: l, BlockTime: bt, Hash: hash})
if l > r.Max {
r.Max = l
}
Expand Down Expand Up @@ -123,11 +124,12 @@ func GenerateFromBlockStore(s BlockStore) (*Reports, error) {
id uuid.UUID
l time.Duration
bt time.Time
hash []byte
connections, rate, size uint64
err error
}
type txData struct {
tx []byte
tx types.Tx
bt time.Time
}
reports := &Reports{
Expand Down Expand Up @@ -161,6 +163,7 @@ func GenerateFromBlockStore(s BlockStore) (*Reports, error) {
pdc <- payloadData{
l: l,
bt: b.bt,
hash: b.tx.Hash(),
id: uuid.UUID(*idb),
connections: p.Connections,
rate: p.Rate,
Expand Down Expand Up @@ -202,7 +205,7 @@ func GenerateFromBlockStore(s BlockStore) (*Reports, error) {
reports.addError()
continue
}
reports.addDataPoint(pd.id, pd.l, pd.bt, pd.connections, pd.rate, pd.size)
reports.addDataPoint(pd.id, pd.l, pd.bt, pd.hash, pd.connections, pd.rate, pd.size)
}
reports.calculateAll()
return reports, nil
Expand Down

0 comments on commit cdd3479

Please sign in to comment.