aboutsummaryrefslogtreecommitdiffstats
path: root/integration_test/latency.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-08-21 16:43:37 +0800
committerGitHub <noreply@github.com>2018-08-21 16:43:37 +0800
commit2c816b5d636b8f7decd234582470a3d4c6b4a93a (patch)
tree5eff9d5f035dda8e3b2632ecce41f3c192e90f21 /integration_test/latency.go
parente8f99372159a89fb3128b870de1733a4777a5144 (diff)
downloadtangerine-consensus-2c816b5d636b8f7decd234582470a3d4c6b4a93a.tar
tangerine-consensus-2c816b5d636b8f7decd234582470a3d4c6b4a93a.tar.gz
tangerine-consensus-2c816b5d636b8f7decd234582470a3d4c6b4a93a.tar.bz2
tangerine-consensus-2c816b5d636b8f7decd234582470a3d4c6b4a93a.tar.lz
tangerine-consensus-2c816b5d636b8f7decd234582470a3d4c6b4a93a.tar.xz
tangerine-consensus-2c816b5d636b8f7decd234582470a3d4c6b4a93a.tar.zst
tangerine-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 'integration_test/latency.go')
-rw-r--r--integration_test/latency.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/integration_test/latency.go b/integration_test/latency.go
index 383d069..8f06084 100644
--- a/integration_test/latency.go
+++ b/integration_test/latency.go
@@ -28,17 +28,27 @@ type LatencyModel interface {
Delay() time.Duration
}
-// normalLatencyModel would return latencies in normal distribution.
-type normalLatencyModel struct {
+// NormalLatencyModel would return latencies in normal distribution.
+type NormalLatencyModel struct {
Sigma float64
Mean float64
}
// Delay implements LatencyModel interface.
-func (m *normalLatencyModel) Delay() time.Duration {
+func (m *NormalLatencyModel) Delay() time.Duration {
delay := rand.NormFloat64()*m.Sigma + m.Mean
if delay < 0 {
delay = m.Sigma / 2
}
return time.Duration(delay) * time.Millisecond
}
+
+// FixedLatencyModel return fixed latencies.
+type FixedLatencyModel struct {
+ Latency float64
+}
+
+// Delay implements LatencyModel interface.
+func (m *FixedLatencyModel) Delay() time.Duration {
+ return time.Duration(m.Latency) * time.Millisecond
+}