mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-05 13:05:09 +00:00
* loadtime: add block time to the data point (#9484)
This pull request adds the block time as the unix time since the epoch to the `report` tool's csv output.
```csv
...
a7a8b903-1136-4da1-97aa-d25da7b4094f,1614226790,1663707084905417366,4,200,1024
a7a8b903-1136-4da1-97aa-d25da7b4094f,1614196724,1663707084905417366,4,200,1024
a7a8b903-1136-4da1-97aa-d25da7b4094f,1613097336,1663707084905417366,4,200,1024
a7a8b903-1136-4da1-97aa-d25da7b4094f,1609365168,1663707084905417366,4,200,1024
a7a8b903-1136-4da1-97aa-d25da7b4094f,1617199169,1663707084905417366,4,200,1024
a7a8b903-1136-4da1-97aa-d25da7b4094f,1615197134,1663707084905417366,4,200,1024
a7a8b903-1136-4da1-97aa-d25da7b4094f,1610399447,1663707084905417366,4,200,1024
...
```
#### PR checklist
- [ ] Tests written/updated, or no tests needed
- [ ] `CHANGELOG_PENDING.md` updated, or no changelog entry needed
- [ ] Updated relevant documentation (`docs/`) and code comments, or no
documentation updates needed
(cherry picked from commit 5fe1a72416)
* lint fix
Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com>
Co-authored-by: William Banfield <wbanfield@gmail.com>
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", "connections", "rate", "size"}
|
res[0] = []string{"experiment_id", "duration_ns", "block_time", "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), 10), connStr, rateStr, sizeStr}
|
res[offset+i] = []string{idStr, strconv.FormatInt(int64(v.Duration), 10), strconv.FormatInt(v.BlockTime.UnixNano(), 10), connStr, rateStr, sizeStr} //nolint: lll
|
||||||
}
|
}
|
||||||
offset += len(r.All)
|
offset += len(r.All)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ type BlockStore interface {
|
|||||||
LoadBlock(int64) *types.Block
|
LoadBlock(int64) *types.Block
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DataPoint contains the set of data collected for each transaction.
|
||||||
|
type DataPoint struct {
|
||||||
|
Duration time.Duration
|
||||||
|
BlockTime time.Time
|
||||||
|
}
|
||||||
|
|
||||||
// Report contains the data calculated from reading the timestamped transactions
|
// Report contains the data calculated from reading the timestamped transactions
|
||||||
// of each block found in the blockstore.
|
// of each block found in the blockstore.
|
||||||
type Report struct {
|
type Report struct {
|
||||||
@@ -38,7 +44,7 @@ type Report struct {
|
|||||||
// All contains all data points gathered from all valid transactions.
|
// All contains all data points gathered from all valid transactions.
|
||||||
// The order of the contents of All is not guaranteed to be match the order of transactions
|
// The order of the contents of All is not guaranteed to be match the order of transactions
|
||||||
// in the chain.
|
// in the chain.
|
||||||
All []time.Duration
|
All []DataPoint
|
||||||
|
|
||||||
// used for calculating average during report creation.
|
// used for calculating average during report creation.
|
||||||
sum int64
|
sum int64
|
||||||
@@ -62,7 +68,7 @@ func (rs *Reports) ErrorCount() int {
|
|||||||
return rs.errorCount
|
return rs.errorCount
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Reports) addDataPoint(id uuid.UUID, l time.Duration, conns, rate, size uint64) {
|
func (rs *Reports) addDataPoint(id uuid.UUID, l time.Duration, bt time.Time, conns, rate, size uint64) {
|
||||||
r, ok := rs.s[id]
|
r, ok := rs.s[id]
|
||||||
if !ok {
|
if !ok {
|
||||||
r = Report{
|
r = Report{
|
||||||
@@ -75,7 +81,7 @@ func (rs *Reports) addDataPoint(id uuid.UUID, l time.Duration, conns, rate, size
|
|||||||
}
|
}
|
||||||
rs.s[id] = r
|
rs.s[id] = r
|
||||||
}
|
}
|
||||||
r.All = append(r.All, l)
|
r.All = append(r.All, DataPoint{Duration: l, BlockTime: bt})
|
||||||
if l > r.Max {
|
if l > r.Max {
|
||||||
r.Max = l
|
r.Max = l
|
||||||
}
|
}
|
||||||
@@ -116,6 +122,7 @@ func GenerateFromBlockStore(s BlockStore) (*Reports, error) {
|
|||||||
type payloadData struct {
|
type payloadData struct {
|
||||||
id uuid.UUID
|
id uuid.UUID
|
||||||
l time.Duration
|
l time.Duration
|
||||||
|
bt time.Time
|
||||||
connections, rate, size uint64
|
connections, rate, size uint64
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
@@ -150,10 +157,11 @@ func GenerateFromBlockStore(s BlockStore) (*Reports, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
l := b.bt.Sub(p.Time.AsTime())
|
l := b.bt.Sub(p.Time.AsTime())
|
||||||
b := (*[16]byte)(p.Id)
|
idb := (*[16]byte)(p.Id)
|
||||||
pdc <- payloadData{
|
pdc <- payloadData{
|
||||||
l: l,
|
l: l,
|
||||||
id: uuid.UUID(*b),
|
bt: b.bt,
|
||||||
|
id: uuid.UUID(*idb),
|
||||||
connections: p.Connections,
|
connections: p.Connections,
|
||||||
rate: p.Rate,
|
rate: p.Rate,
|
||||||
size: p.Size,
|
size: p.Size,
|
||||||
@@ -194,16 +202,16 @@ func GenerateFromBlockStore(s BlockStore) (*Reports, error) {
|
|||||||
reports.addError()
|
reports.addError()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
reports.addDataPoint(pd.id, pd.l, pd.connections, pd.rate, pd.size)
|
reports.addDataPoint(pd.id, pd.l, pd.bt, pd.connections, pd.rate, pd.size)
|
||||||
}
|
}
|
||||||
reports.calculateAll()
|
reports.calculateAll()
|
||||||
return reports, nil
|
return reports, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func toFloat(in []time.Duration) []float64 {
|
func toFloat(in []DataPoint) []float64 {
|
||||||
r := make([]float64, len(in))
|
r := make([]float64, len(in))
|
||||||
for i, v := range in {
|
for i, v := range in {
|
||||||
r[i] = float64(int64(v))
|
r[i] = float64(int64(v.Duration))
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user