()
| 39 | |
| 40 | |
| 41 | def 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 | |
| 59 | def _backends(root: Path) -> Iterator[tuple[str, Callable[[], filelock.BaseFileLock]]]: |
no test coverage detected