-
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.
Adding extra py algorithm for testing
- Loading branch information
1 parent
46ff958
commit 343e67f
Showing
1 changed file
with
27 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import time | ||
import os | ||
import random | ||
from multiprocessing import Process | ||
|
||
# there is no memory allocation test for now | ||
def thr(duration,memory_alloc): | ||
initial_timestamp=time.time() | ||
while True: | ||
time_now=time.time() | ||
if time_now>initial_timestamp+duration: break | ||
rand=random.getrandbits(32) | ||
|
||
if __name__ =="__main__": | ||
threads_nr=os.getenv('THREADS', 8) | ||
duration = os.getenv('SECONDS', 2*60) | ||
memory = os.getenv('MEMORY', 1024) | ||
print(f"Starting {threads_nr} threads for a duration of {duration} seconds each...") | ||
t = [None] * threads_nr | ||
for n in range(0,threads_nr): | ||
t[n] = Process(target=thr, args=(duration,memory,)) | ||
t[n].start() | ||
|
||
# wait for threads to complete | ||
for n in range(0,threads_nr): | ||
t[n-1].join() | ||
print("Done!") |