tests: import cpu_load.py.

This commit is contained in:
David Wilson 2018-07-04 15:22:18 +00:00
parent e24eddb1ce
commit 3e48f95439
1 changed files with 21 additions and 0 deletions

21
tests/soak/cpu_load.py Normal file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env python
"""
Put the machine's CPUs under pressure to increase the likelihood of scheduling
weirdness. Useful for exposing otherwise difficult to hit races in the library.
"""
import multiprocessing
def burn():
while 1: pass
mul = 2
count = int(mul * multiprocessing.cpu_count())
print count
procs = [multiprocessing.Process(target=burn)
for _ in range(count)]
for i, proc in enumerate(procs):
print([i])
proc.start()