Exemple #1
0
    def test_error_not_initialized(self):
        """Test the error when timer has been not initialized"""
        t = Timer(matlab_like=True)

        with pytest.raises(TimerError):
            assert t.stop()
Exemple #2
0
    def test_error_not_initialized_non_matlab_like_key(self):
        """Test the error when timer has been not initialized"""
        t = Timer(matlab_like=False)

        with pytest.raises(TimerError):
            assert t.stop("init")
Exemple #3
0
print("\nNested Tic Toc")
tic()
for i in range(2):
    tic()
    time.sleep(1)
    elapsed = toc()
    print("[IN LOOP] Elapsed time:", elapsed)
print("[OUT LOOP] Elapsed time:", toc())

print("\n>>>Using Timer class")
print("\nSimple")
t = Timer()
t.start()
time.sleep(1)
elapsed = t.stop()
print("Elapsed time:", elapsed)

print("\nNested")
t.start()
for i in range(2):
    t.start()
    time.sleep(1)
    elapsed = t.stop()
    print("[IN LOOP] Elapsed time:", elapsed)
print("[OUT LOOP] Elapsed time:", t.stop())

print(">>> Tic Toc, v2 (non matlab-like)")
print("\nSimple Tic Toc")
tic2()
time.sleep(1)