diff options
author | Mission Liao <mission.liao@dexon.org> | 2018-08-21 16:43:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-21 16:43:37 +0800 |
commit | 2c816b5d636b8f7decd234582470a3d4c6b4a93a (patch) | |
tree | 5eff9d5f035dda8e3b2632ecce41f3c192e90f21 /core/test/scheduler-event.go | |
parent | e8f99372159a89fb3128b870de1733a4777a5144 (diff) | |
download | dexon-consensus-2c816b5d636b8f7decd234582470a3d4c6b4a93a.tar dexon-consensus-2c816b5d636b8f7decd234582470a3d4c6b4a93a.tar.gz dexon-consensus-2c816b5d636b8f7decd234582470a3d4c6b4a93a.tar.bz2 dexon-consensus-2c816b5d636b8f7decd234582470a3d4c6b4a93a.tar.lz dexon-consensus-2c816b5d636b8f7decd234582470a3d4c6b4a93a.tar.xz dexon-consensus-2c816b5d636b8f7decd234582470a3d4c6b4a93a.tar.zst dexon-consensus-2c816b5d636b8f7decd234582470a3d4c6b4a93a.zip |
simulation: add simulation with scheduler (#71)
- Add new field in test.Event: HistoryIndex
HistoryIndex allow us to access them by their position in event history.
- Record local time in test.App when receiving events.
- Add statisitics module for slices of test.Event.
- add new command line utility *dexcon-simulation-with-scheduler
to verify the execution time of core.Consensus.
Diffstat (limited to 'core/test/scheduler-event.go')
-rw-r--r-- | core/test/scheduler-event.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/core/test/scheduler-event.go b/core/test/scheduler-event.go index 60411b4..85968c5 100644 --- a/core/test/scheduler-event.go +++ b/core/test/scheduler-event.go @@ -25,6 +25,8 @@ import ( // Event defines a scheduler event. type Event struct { + // HistoryIndex is the index of this event in history. + HistoryIndex int // ValidatorID is the ID of handler that this event deginated to. ValidatorID types.ValidatorID // Time is the expected execution time of this event. @@ -33,9 +35,8 @@ type Event struct { ExecError error // Payload is application specific data carried by this event. Payload interface{} - // ParentTime is the time of parent event, this field is essential when - // we need to calculate the latency the handler assigned. - ParentTime time.Time + // ParentHistoryIndex is the index of parent event in history. + ParentHistoryIndex int // ExecInterval is the latency to execute this event ExecInterval time.Duration } @@ -69,8 +70,10 @@ func NewEvent( vID types.ValidatorID, when time.Time, payload interface{}) *Event { return &Event{ - ValidatorID: vID, - Time: when, - Payload: payload, + HistoryIndex: -1, + ParentHistoryIndex: -1, + ValidatorID: vID, + Time: when, + Payload: payload, } } |