Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- log
- Elasticsearch
- audit
- RHEL
- 디렉토리
- GNOME
- Audit Log
- K8S
- centos 7.5
- zabbix
- C
- Shell
- bash
- PostgreSQL
- JSON
- 빅데이터
- 크롬
- CentOS
- Chrome
- Python
- Elk
- 파이썬
- 서울시민카드
- yum
- syslog
- Linux
- Kubernetes
- GPU
- docker
- rsyslog
Archives
- Today
- Total
Sysops Notepad
[Python] CPU load Test 본문
728x90
#!/usr/bin/env python
"""
Produces load on all available CPU cores
Updated with suggestion to prevent Zombie processes
Linted for Python 3
Source:
insaner @ http://danielflannery.ie/simulate-cpu-load-with-python/#comment-34130
"""
from multiprocessing import Pool
from multiprocessing import cpu_count
import signal
stop_loop = 0
def exit_chld(x, y):
global stop_loop
stop_loop = 1
def f(x):
global stop_loop
while not stop_loop:
x*x
signal.signal(signal.SIGINT, exit_chld)
if __name__ == '__main__':
processes = cpu_count()
print('-' * 20)
print('Running load on CPU(s)')
print('Utilizing %d cores' % processes)
print('-' * 20)
pool = Pool(processes)
pool.map(f, range(processes))
원본:
https://github.com/insaner/cpu_stress_cores.py
http://danielflannery.ie/simulate-cpu-load-with-python/
728x90
'업무 > dev' 카테고리의 다른 글
정규표현식(Regular Expression) 사이트 및 팁 (0) | 2021.04.22 |
---|---|
[Python] HTML 파싱 하기 (0) | 2019.03.11 |
[python] logging 모듈 사용하기 (0) | 2019.02.26 |
[Linux,linux] Centos Multi GPU 환경에서 특정 GPU만 사용하기 (1) | 2019.02.20 |
[Python] 파이썬 람다(lambda) 간단한 사용법 (0) | 2019.02.20 |
Comments