tbot_contrib.timing

Testcases for timing the duration of other tests.

tbot_contrib.timing.time_testcase(testcase: Callable, *args: Any, **kwargs: Any) Tuple[float, Any][source]

Time the duration of a testcase.

Parameters:
  • testcase – Testcase to call.

  • args,kwargs – Arguments to pass to the testcase.

Returns:

A tuple of the time (in seconds) and the testcase’s return value.

Example:

from tbot_contrib import timing

def foo(arg1: str, arg2: int) -> int:
    ...

duration, ret = timing.time_testcase(foo, "hello", arg2=42)

New in version 0.8.2.

tbot_contrib.timing.time_testcase_statistics(testcase: Callable, *args: Any, runs: int = 10, sleep: float = 0, **kwargs: Any) None[source]

Take multiple measurements about the run-time of a testcase and return/display statistics.

Parameters:
  • testcase – Testcase to call.

  • args,kwargs – Arguments to pass to the testcase.

  • runs (int) – How many samples to take.

  • sleep (float) – How much time to sleep in between the runs. Example use: Maybe the board does not discharge quick enough so it can cause troubles when the subsecuent testcase run tries to boot again the board

New in version 0.8.2.