Index: dolfin/python/test/unit/common/test_timer.py =================================================================== --- dolfin.orig/python/test/unit/common/test_timer.py 2024-01-04 02:03:57.161702192 +0100 +++ dolfin/python/test/unit/common/test_timer.py 2024-01-04 02:04:43.060998594 +0100 @@ -29,6 +29,10 @@ # Seed random generator for determinism random.seed(0) +# resolution of the timer is not precise, +# need to allow some tolerance +timing_resolution = 0.015 + def get_random_task_name(): """Get pseudo-random string""" return hex(random.randint(0, 1e32)) @@ -40,20 +44,20 @@ # Execute task in the context manager with Timer(task) as t: - sleep(0.05) - assert t.elapsed()[0] >= 0.05 + sleep(0.1) + assert t.elapsed()[0] >= 0.1 - timing_resolution # Check timing t = timing(task, TimingClear.clear) assert t[0] == 1 - assert t[1] >= 0.05 + assert t[1] >= 0.05 - timing_resolution def test_context_manager_anonymous(): """Test that anonymous Timer works as context manager""" with Timer() as t: - sleep(0.05) - assert t.elapsed()[0] >= 0.05 + sleep(0.1) + assert t.elapsed()[0] >= 0.1 - timing_resolution # Test case for decorated free function @@ -116,7 +120,7 @@ # Check that correct timing was recorded t = timing(task, TimingClear.clear) assert t[0] == 2 - assert t[1] >= 0.1 + assert t[1] >= 0.1 - timing_resolution def test_decorator_timer_scope(): @@ -158,4 +162,4 @@ sleep(0.05) # Check that sleeping above did not influence timer - assert timing(task, TimingClear.clear)[1] < 0.1 + assert timing(task, TimingClear.clear)[1] < 0.1 + timing_resolution