Ejemplo n.º 1
0
def test_count_calls_multiple_funtions(f, g):
    f = profile(f)
    g = profile(g)
    assert f.count_calls() == 0
    assert g.count_calls() == 0
    f()
    f()
    g()
    g()
    g()
    assert f.count_calls() == 2
    assert g.count_calls() == 3
Ejemplo n.º 2
0
def test_average_time(f):
    f = profile(f)
    f()
    time.sleep(.001)
    f()
    avg = f.average_execution_time()
    assert avg > 0
Ejemplo n.º 3
0
def test_execution_times(f):
    f = profile(f)
    assert f.count_calls() == 0
    f()
    f()
    times = f.execution_times()
    assert len(times) == 2
Ejemplo n.º 4
0
def profile_ranker(ranking_function, set_size, repetitions):
    info = []
    base_lib.rank_elements = profile(base_lib.rank_elements)
    for _ in range(repetitions):
        print('.', end='', flush=True)
        base_lib.rank_elements.reset_profile()
        elements = create_element_set(set_size)
        rank = ranking_function(elements)
        assert is_ranking_correct(elements, rank)
        info.append({
            'set_size': set_size,
            'rank_call_count': base_lib.rank_elements.count_calls()
        })
    print()
    return info
Ejemplo n.º 5
0
def test_total_time(f):
    f = profile(f)
    f()
    f()
    tot = f.average_execution_time()
    assert tot > 0
Ejemplo n.º 6
0
def test_count_calls(f):
    f = profile(f)
    assert f.count_calls() == 0
    f()
    f()
    assert f.count_calls() == 2
Ejemplo n.º 7
0
def test_setup_profile(f):
    f = profile(f)
    f()