change the log replayer to be more realistic

This commit is contained in:
Michael Hudson-Doyle 2017-10-19 16:49:48 +13:00
parent 4616a600fe
commit 2779bac01a
1 changed files with 6 additions and 2 deletions

View File

@ -36,8 +36,12 @@ class FakeEvent:
def as_dict(self):
return self._ev_dict
prev_ev = None
for line in open(json_file):
d = json.loads(line.strip())
ev = FakeEvent(d)
events.report_event(ev)
time.sleep(random.expovariate(2))
if prev_ev is not None:
events.report_event(prev_ev)
time.sleep(min((ev.timestamp - prev_ev.timestamp)/4, 2))
prev_ev = ev
events.report_event(prev_ev)