def test_start(): prf = Profiler() prf.start() prf.end() t_1 = prf.getRuntime() prf.start() f() prf.end() t_2 = prf.getRuntime() assert t_1 != t_2
def test_getters(): runs = 3 prf = Profiler() for i in range(runs): prf.start() f() prf.end() assert prf.getRuntime() == pstats.Stats(prf.prf).__dict__["total_tt"] assert (prf.getAverageRuntime(runs) == pstats.Stats( prf.prf).__dict__["total_tt"] / runs) assert prf.getRuntime() != prf.getAverageRuntime(runs)