Test that named Timer works.
()
| 14 | |
| 15 | |
| 16 | def test_timer(): |
| 17 | """Test that named Timer works.""" |
| 18 | dt = 0.05 |
| 19 | task = "test_named_str" |
| 20 | t = common.Timer(task) |
| 21 | t.start() |
| 22 | sleep(dt) |
| 23 | t.stop() |
| 24 | assert t.elapsed().total_seconds() > 0.9 * dt |
| 25 | |
| 26 | t.resume() |
| 27 | sleep(dt) |
| 28 | t.stop() |
| 29 | assert t.elapsed().total_seconds() > 2 * 0.9 * dt |
| 30 | |
| 31 | t.flush() |
| 32 | t = common.timing(task) |
| 33 | assert t[0] == 1 |
| 34 | assert t[1].total_seconds() > 0.045 |
| 35 | |
| 36 | |
| 37 | def test_timer_flush_stop(): |