Beispiel #1
0
def test_rt_slow_sim_no_error(env, log):
    """Test ignoring slow simulations."""
    env.start(process(env, log, 0.1, 1))

    start = perf_counter()
    simulate(env, 2, 0.05, strict=False)
    duration = perf_counter() - start

    assert check_duration(duration, 2 * 0.1)
    assert log == [1]
Beispiel #2
0
def test_rt(env, log, factor):
    """Basic tests for simulate()."""
    env.start(process(env, log, 0.01, 1))
    env.start(process(env, log, 0.02, 1))

    start = perf_counter()
    simulate(env, 2, factor=factor)
    duration = perf_counter() - start

    assert check_duration(duration, 2 * factor)
    assert log == [1, 1]
Beispiel #3
0
def test_rt_multiple_call(env, log):
    """Test multiple calls to simulate()."""
    env.start(process(env, log, 0.01, 2))
    env.start(process(env, log, 0.01, 3))

    start = perf_counter()
    simulate(env, 5, factor=0.05)
    duration = perf_counter() - start

    # assert almost_equal(duration, 0.2)
    assert check_duration(duration, 5 * 0.05)
    assert log == [2, 3, 4]

    start = perf_counter()
    simulate(env, 12, factor=0.05)
    duration = perf_counter() - start

    assert check_duration(duration, 7 * 0.05)
    assert log == [2, 3, 4, 6, 6, 8, 9, 10]