mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-03 03:35:19 +00:00
* Extend the load report tool to include transactions' hashes (#9509)
* Add transaction hash to raw data
* Add hash in formatted output
* Cosmetic
(cherry picked from commit cdd3479f20)
# Conflicts:
# test/loadtime/cmd/report/main.go
* Resolve conflict
* Appease linter
Co-authored-by: Sergio Mena <sergio@informal.systems>
This commit is contained in:
@@ -87,7 +87,7 @@ func toCSVRecords(rs []report.Report) [][]string {
|
|||||||
}
|
}
|
||||||
res := make([][]string, total+1)
|
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
|
offset := 1
|
||||||
for _, r := range rs {
|
for _, r := range rs {
|
||||||
idStr := r.ID.String()
|
idStr := r.ID.String()
|
||||||
@@ -95,7 +95,7 @@ func toCSVRecords(rs []report.Report) [][]string {
|
|||||||
rateStr := strconv.FormatInt(int64(r.Rate), 10)
|
rateStr := strconv.FormatInt(int64(r.Rate), 10)
|
||||||
sizeStr := strconv.FormatInt(int64(r.Size), 10)
|
sizeStr := strconv.FormatInt(int64(r.Size), 10)
|
||||||
for i, v := range r.All {
|
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} //nolint: lll
|
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} //nolint: lll
|
||||||
}
|
}
|
||||||
offset += len(r.All)
|
offset += len(r.All)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ type BlockStore interface {
|
|||||||
type DataPoint struct {
|
type DataPoint struct {
|
||||||
Duration time.Duration
|
Duration time.Duration
|
||||||
BlockTime time.Time
|
BlockTime time.Time
|
||||||
|
Hash []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report contains the data calculated from reading the timestamped transactions
|
// Report contains the data calculated from reading the timestamped transactions
|
||||||
@@ -68,7 +69,7 @@ func (rs *Reports) ErrorCount() int {
|
|||||||
return rs.errorCount
|
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]
|
r, ok := rs.s[id]
|
||||||
if !ok {
|
if !ok {
|
||||||
r = Report{
|
r = Report{
|
||||||
@@ -81,7 +82,7 @@ func (rs *Reports) addDataPoint(id uuid.UUID, l time.Duration, bt time.Time, con
|
|||||||
}
|
}
|
||||||
rs.s[id] = r
|
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 {
|
if l > r.Max {
|
||||||
r.Max = l
|
r.Max = l
|
||||||
}
|
}
|
||||||
@@ -123,11 +124,12 @@ func GenerateFromBlockStore(s BlockStore) (*Reports, error) {
|
|||||||
id uuid.UUID
|
id uuid.UUID
|
||||||
l time.Duration
|
l time.Duration
|
||||||
bt time.Time
|
bt time.Time
|
||||||
|
hash []byte
|
||||||
connections, rate, size uint64
|
connections, rate, size uint64
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
type txData struct {
|
type txData struct {
|
||||||
tx []byte
|
tx types.Tx
|
||||||
bt time.Time
|
bt time.Time
|
||||||
}
|
}
|
||||||
reports := &Reports{
|
reports := &Reports{
|
||||||
@@ -161,6 +163,7 @@ func GenerateFromBlockStore(s BlockStore) (*Reports, error) {
|
|||||||
pdc <- payloadData{
|
pdc <- payloadData{
|
||||||
l: l,
|
l: l,
|
||||||
bt: b.bt,
|
bt: b.bt,
|
||||||
|
hash: b.tx.Hash(),
|
||||||
id: uuid.UUID(*idb),
|
id: uuid.UUID(*idb),
|
||||||
connections: p.Connections,
|
connections: p.Connections,
|
||||||
rate: p.Rate,
|
rate: p.Rate,
|
||||||
@@ -202,7 +205,7 @@ func GenerateFromBlockStore(s BlockStore) (*Reports, error) {
|
|||||||
reports.addError()
|
reports.addError()
|
||||||
continue
|
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()
|
reports.calculateAll()
|
||||||
return reports, nil
|
return reports, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user