-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserial_test.py
More file actions
40 lines (35 loc) · 873 Bytes
/
Copy pathserial_test.py
File metadata and controls
40 lines (35 loc) · 873 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
34
35
36
37
38
39
40
import numpy as np
import time
import os
import math
def task(bound):
l = []
#np.random.seed((os.getpid() * int(time.time())) % 123456789)
# bound should be > 50000
x = [math.sqrt(i) for i in range(1, bound)]
a = sum(x)
b = sum(x)
return a,b
#r = abs(np.random.normal(1,1))
#time.sleep(r)
#write(r)
def write(data):
try:
f = open("race.txt",'a')
w_str = (
f"{data}\n"
f"{time.time()}\n"
f"print('module name:', {__name__})\n"
f"print('parent process:', {os.getppid()})\n"
f"print('process id:', {os.getpid()})\n"
)
f.write(w_str)
f.close()
finally:
pass
st = time.time()
global_list = []
for i in range(4):
global_list.append(task(100000000))
print(global_list)
print(f"Time: {time.time()-st}")