-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- full : full resource in specific time - status : get current status of resource - job : background normal behavior stimate controller
- Loading branch information
1 parent
2ccf23a
commit 35ad4eb
Showing
8 changed files
with
126 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import time | ||
import multiprocessing | ||
from core.config import get_settings | ||
|
||
settings = get_settings() | ||
|
||
def full_cpu_in_duration(duration: int): | ||
now = time.time() | ||
print("time", now) | ||
print(f"full cpu in {duration} seconds") | ||
|
||
i=0 | ||
while True: | ||
if time.time() > now + duration: | ||
break | ||
i += 1 | ||
print("time", time.time()) | ||
|
||
def create_full_cpu_process(duration: int): | ||
''' | ||
create 4 process to full cpu in duration seconds | ||
''' | ||
|
||
for _ in range(settings.full_cpu_process_count): | ||
p = multiprocessing.Process(target=full_cpu_in_duration, args=(duration,)) | ||
p.start() | ||
|
||
|
||
""" | ||
refence: | ||
https://stackoverflow.com/questions/6317818/eat-memory-using-python | ||
""" | ||
def full_ram_in_duration(duration: int): | ||
now = time.time() | ||
print("time", now) | ||
print(f"full ram in {duration} seconds") | ||
|
||
cnt = 0 | ||
a = bytearray(settings.full_ram_byte) | ||
while True: | ||
if time.time() > now + duration: | ||
break | ||
|
||
try: | ||
a = a + bytearray(settings.full_ram_byte) | ||
cnt += 1 | ||
except MemoryError: | ||
break | ||
|
||
if time.time() < now + duration: | ||
time.sleep(now + duration - time.time()) | ||
|
||
# in GB | ||
print(f"Allocated {cnt} GB in {duration} seconds") | ||
print("time", time.time()) | ||
|
||
def create_full_rem_process(duration: int): | ||
p = multiprocessing.Process(target=full_ram_in_duration, args=(duration,)) | ||
p.start() | ||
return p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.