diff options
Diffstat (limited to 'integration_test/stats.go')
-rw-r--r-- | integration_test/stats.go | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/integration_test/stats.go b/integration_test/stats.go index ae8ded4..11b1db0 100644 --- a/integration_test/stats.go +++ b/integration_test/stats.go @@ -15,7 +15,7 @@ var ( ) // StatsSet represents accumulatee result of a group of related events -// (ex. All events from one validator). +// (ex. All events from one node). type StatsSet struct { ProposedBlockCount int ReceivedBlockCount int @@ -81,16 +81,16 @@ func (s *StatsSet) newBlockReceiveEvent( // done would divide the latencies we cached with related event count. This way // to calculate average latency is more accurate. -func (s *StatsSet) done(validatorCount int) { - s.ProposingLatency /= time.Duration(s.ProposedBlockCount - validatorCount) +func (s *StatsSet) done(nodeCount int) { + s.ProposingLatency /= time.Duration(s.ProposedBlockCount - nodeCount) s.ReceivingLatency /= time.Duration(s.ReceivedBlockCount) s.PrepareExecLatency /= time.Duration(s.ProposedBlockCount) s.ProcessExecLatency /= time.Duration(s.ReceivedBlockCount) } -// Stats is statistics of a slice of test.Event generated by validators. +// Stats is statistics of a slice of test.Event generated by nodes. type Stats struct { - ByValidator map[types.ValidatorID]*StatsSet + ByNode map[types.NodeID]*StatsSet All *StatsSet BPS float64 ExecutionTime time.Duration @@ -99,12 +99,12 @@ type Stats struct { // NewStats constructs an Stats instance by providing a slice of // test.Event. func NewStats( - history []*test.Event, apps map[types.ValidatorID]*test.App) ( + history []*test.Event, apps map[types.NodeID]*test.App) ( stats *Stats, err error) { stats = &Stats{ - ByValidator: make(map[types.ValidatorID]*StatsSet), - All: &StatsSet{}, + ByNode: make(map[types.NodeID]*StatsSet), + All: &StatsSet{}, } if err = stats.calculate(history, apps); err != nil { stats = nil @@ -114,11 +114,11 @@ func NewStats( } func (stats *Stats) calculate( - history []*test.Event, apps map[types.ValidatorID]*test.App) error { + history []*test.Event, apps map[types.NodeID]*test.App) error { defer func() { - stats.All.done(len(stats.ByValidator)) - for _, set := range stats.ByValidator { + stats.All.done(len(stats.ByNode)) + for _, set := range stats.ByNode { set.done(1) } }() @@ -132,13 +132,13 @@ func (stats *Stats) calculate( case evtProposeBlock: stats.All.newBlockProposeEvent( e, payload, history) - stats.getStatsSetByValidator(e.ValidatorID).newBlockProposeEvent( + stats.getStatsSetByNode(e.NodeID).newBlockProposeEvent( e, payload, history) case evtReceiveBlock: stats.All.newBlockReceiveEvent( - e, payload, history, apps[e.ValidatorID]) - stats.getStatsSetByValidator(e.ValidatorID).newBlockReceiveEvent( - e, payload, history, apps[e.ValidatorID]) + e, payload, history, apps[e.NodeID]) + stats.getStatsSetByNode(e.NodeID).newBlockReceiveEvent( + e, payload, history, apps[e.NodeID]) default: return ErrUnknownConsensusEventType } @@ -146,13 +146,13 @@ func (stats *Stats) calculate( return nil } -func (stats *Stats) getStatsSetByValidator( - vID types.ValidatorID) (s *StatsSet) { +func (stats *Stats) getStatsSetByNode( + vID types.NodeID) (s *StatsSet) { - s = stats.ByValidator[vID] + s = stats.ByNode[vID] if s == nil { s = &StatsSet{} - stats.ByValidator[vID] = s + stats.ByNode[vID] = s } return } @@ -160,10 +160,10 @@ func (stats *Stats) getStatsSetByValidator( func (stats *Stats) summary(history []*test.Event) { // Find average delivered block count among all blocks. totalConfirmedBlocks := 0 - for _, s := range stats.ByValidator { + for _, s := range stats.ByNode { totalConfirmedBlocks += s.DeliveredBlockCount } - averageConfirmedBlocks := totalConfirmedBlocks / len(stats.ByValidator) + averageConfirmedBlocks := totalConfirmedBlocks / len(stats.ByNode) // Find execution time. // Note: it's a simplified way to calculate the execution time: |