def __init__(self, step=60000, maxIteration=0): self._counter = 0 self._maxIteration = maxIteration self._step = step self._clock = 0 # clock = counter * step self._DATE_FORMAT = "%Y-%m-%d %H:%M:%S %Z%z" self._run = True self.world = World() # logging LOG_FORMAT = "%(levelname)s - %(message)s" logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)
def _simulate(self, instance_creator: InstanceCreator, request_generator: RequestGenerator, load_generator: LoadGenerator = None, log_progress=False) -> (SimulatorResult, list): """ Runs a single simulation. To process the incoming requests by the request_generator (quantity per simulation step determinted by the load_generator), new instances are created using the instance_creator. :param instance_creator: InstanceCreator, to create instances :param request_generator: RequestGenerator, to create requests :param load_generator: LoadGenerator, to generate load :return: SimulatorResult """ world = World(instance_creator) simulator = Simulator(self.config, world, request_generator, log_progress) result, requests = simulator.run(load_generator) return result, requests