MCPcopy Create free account
hub / github.com/tox-dev/filelock / main

Function main

tasks/benchmark.py:41–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39
40
41def main() -> None:
42 build = "gil" if getattr(sys, "_is_gil_enabled", lambda: True)() else "free-threaded"
43 print(
44 f"filelock {filelock.__version__} | {platform.python_implementation()} {platform.python_version()} ({build}) | "
45 f"{platform.system()} {platform.machine()} | {os.cpu_count()} cpus"
46 )
47 samples: list[Sample] = []
48 with TemporaryDirectory(prefix="filelock-bench-") as directory:
49 root = Path(directory)
50 samples += [_timed(f"construct {name}", factory, unit="us", scale=1e6) for name, factory in _backends(root)]
51 samples += _uncontended(root)
52 samples.append(_timeout_cpu(root))
53 samples.append(_descriptor_growth(root))
54 samples += _cancellation_latency(root)
55 samples += _contention(root)
56 _report(samples)
57
58
59def _backends(root: Path) -> Iterator[tuple[str, Callable[[], filelock.BaseFileLock]]]:

Callers 2

benchmark.pyFile · 0.70
_in_subinterpreterFunction · 0.50

Calls 8

_timedFunction · 0.85
_backendsFunction · 0.85
_uncontendedFunction · 0.85
_timeout_cpuFunction · 0.85
_descriptor_growthFunction · 0.85
_cancellation_latencyFunction · 0.85
_contentionFunction · 0.85
_reportFunction · 0.85

Tested by

no test coverage detected