from contextlib import contextmanager
from time import time
import numpy as np
from skan.vendored import thresholding as th


@contextmanager
def timer():
    result = [0.]
    t = time()
    yield result
    result[0] = time() - t


def test_fast_sauvola():
    image = np.random.rand(512, 512)
    w0 = 25
    w1 = 251
    _ = th.threshold_sauvola(image, window_size=3)
    with timer() as t0:
        th.threshold_sauvola(image, window_size=w0)
    with timer() as t1:
        th.threshold_sauvola(image, window_size=w1)
    assert t1[0] < 2 * t0[0]

@@ -1,42 +1,4 @@
-from contextlib import contextmanager%0A
 from
@@ -15,16 +15,16 @@
 rt time%0A
+
 import n
@@ -85,100 +85,215 @@
 h%0A%0A%0A
-@contextmanager%0Adef timer():%0A    result = %5B0.%5D%0A    t = time()%0A    yield result%0A    result%5B0%5D
+class Timer:%0A    def __init__(self):%0A        self.interval = 0%0A%0A    def __enter__(self):%0A        self.t0 = time()%0A        return self%0A%0A    def __exit__(self, exc_type, exc_val, exc_tb):%0A        self.interval
  = t
@@ -300,17 +300,23 @@
 ime() - 
-t
+self.t0
 %0A%0A%0Adef t
@@ -449,33 +449,33 @@
 ize=3)%0A    with 
-t
+T
 imer() as t0:%0A  
@@ -533,17 +533,17 @@
    with 
-t
+T
 imer() a
@@ -617,20 +617,32 @@
 t t1
-%5B0%5D %3C 2 * t0%5B0%5D
+.interval %3C 2 * t0.interval
 %0A

Use timer class instead of weird list