-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtRex.py
More file actions
33 lines (28 loc) · 844 Bytes
/
tRex.py
File metadata and controls
33 lines (28 loc) · 844 Bytes
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
31
32
33
import multiprocessing as mp
from datetime import datetime
import concurrent.futures
import numpy as np
import time
def tAsk(req):
for i in range(1000):
True
def rT(subRex):
with concurrent.futures.ThreadPoolExecutor(max_workers=12) as exe:
exe.map(tAsk,subRex)
def rP():
with concurrent.futures.ProcessPoolExecutor(max_workers=8) as exe:
exe.map(rT, tRex)
if __name__ == "__main__":
rows = 8
cols = 1000000
tRex = np.ndarray((rows,cols,),dtype=object)
for i in range(rows):
for j in range(cols):
tRex[i][j]={}
tRex[i][j]["_id"] = (i + 1) * (j + 1)
tRex[i][j]['Row']=i+1
tRex[i][j]['Col']=j+1
start = time.perf_counter()
rP()
finish = time.perf_counter()
print(f"Finished in {round(finish-start, 2)} seconds")