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

Function _contention

tasks/benchmark.py:149–163  ·  view source on GitHub ↗
(root: Path)

Source from the content-addressed store, hash-verified

147
148
149def _contention(root: Path) -> list[Sample]:
150 samples: list[Sample] = []
151 contention_processes: int = 8
152 for name, path in (("FileLock", root / "c-file.lock"), ("StrictSoftFileLock", root / "c-strict.lock")):
153 started = time.perf_counter()
154 workers = [Process(target=_hammer, args=(name, str(path))) for _ in range(contention_processes)]
155 for worker in workers:
156 worker.start()
157 for worker in workers:
158 worker.join()
159 elapsed = time.perf_counter() - started
160 total = contention_processes * _CONTENTION_ACQUISITIONS
161 per = elapsed * 1e3 / total
162 samples.append(Sample(name=f"contention {name} ({total} acquisitions)", median=per, p95=per, unit="ms/acq"))
163 return samples
164
165
166def _hammer(backend: str, path: str) -> None:

Callers 1

mainFunction · 0.85

Calls 2

SampleClass · 0.85
joinMethod · 0.80

Tested by

no test coverage detected