das-research/study.py

36 lines
1.1 KiB
Python
Raw Normal View History

2022-11-30 14:28:27 +00:00
#! /bin/python3
import time
from DAS import *
def study():
2023-01-13 15:51:27 +00:00
config = Configuration(64, 20, 10, 256, 8, 0, 0)
sim = Simulator(config)
2022-11-30 14:28:27 +00:00
sim.initLogger()
frRange = []
resultRange = []
simCnt = 0
sim.logger.info("Starting simulations:", extra=sim.format)
start = time.time()
2023-01-13 15:51:27 +00:00
for fr in range(0, 100, config.failureRateStep):
2022-11-30 14:28:27 +00:00
if fr % 10 == 0:
sim.logger.info("Failure rate %d %% ..." % fr, extra=sim.format)
sim.resetFailureRate(fr)
result = 0
2023-01-13 15:51:27 +00:00
for i in range(config.maxTries):
2022-11-30 14:28:27 +00:00
sim.initValidators()
sim.initNetwork()
2022-11-30 14:28:27 +00:00
result += sim.run()
simCnt += 1
frRange.append(fr)
2023-01-13 15:51:27 +00:00
resultRange.append((config.maxTries-result)*100/config.maxTries)
2022-11-30 14:28:27 +00:00
end = time.time()
sim.logger.info("A total of %d simulations ran in %d seconds" % (simCnt, end-start), extra=sim.format)
for i in range(len(frRange)):
sim.logger.info("For failure rate of %d we got %d %% success rate in DAS!" % (frRange[i], resultRange[i]), extra=sim.format)
study()