Skip to content

Commit

Permalink
Adding extra py algorithm for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiehewitt15 committed Feb 25, 2025
1 parent 46ff958 commit 343e67f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions metadata/cpumem-test.py
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!")

0 comments on commit 343e67f

Please sign in to comment.