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.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.go')
-rw-r--r-- | core/test/scheduler.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/test/scheduler.go b/core/test/scheduler.go index 023d09f..6a3a40a 100644 --- a/core/test/scheduler.go +++ b/core/test/scheduler.go @@ -165,12 +165,6 @@ func (sch *Scheduler) workerRoutine(wg *sync.WaitGroup) { if sch.stopper.ShouldStop(e.ValidatorID) { sch.cancelFunc() } - // Include the execution interval of parent event to the expected time - // to execute child events. - for _, newEvent := range newEvents { - newEvent.ParentTime = e.Time - newEvent.Time = newEvent.Time.Add(e.ExecInterval) - } return newEvents }() // Record executed events as history. @@ -178,8 +172,15 @@ func (sch *Scheduler) workerRoutine(wg *sync.WaitGroup) { sch.historyLock.Lock() defer sch.historyLock.Unlock() + e.HistoryIndex = len(sch.history) sch.history = append(sch.history, e) }() + // Include the execution interval of parent event to the expected time + // to execute child events. + for _, newEvent := range newEvents { + newEvent.ParentHistoryIndex = e.HistoryIndex + newEvent.Time = newEvent.Time.Add(e.ExecInterval) + } // Add derivated events back to event queue. func() { sch.eventsLock.Lock() |