-
Notifications
You must be signed in to change notification settings - Fork 0
/
what.py
45 lines (37 loc) · 942 Bytes
/
what.py
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
41
42
43
44
45
import os
import time
from threading import Thread
from multiprocessing import Process
doc_list = []
data_path_root = ('./data/')
data_path = os.listdir(data_path_root)
t1 = time.time()
for i in data_path:
with open(os.path.join(data_path_root,i),'r') as file:
doc_list.append(file.read())
t2 = time.time()
print(t2-t1)
t1 = time.time()
def read_file(filename):
with open(os.path.join(data_path_root,i),'r') as file:
file.read()
for i in range(len(data_path),6000):
processes = []
for data in data_path[i:i+6000]:
p = Process(target=read_file,args=(data,))
processes.append(p)
p.start()
for p in processes:
p.join()
t2 = time.time()
print(t2-t1)
# t1 = time.time()
# processes = []
# for i in data_path:
# p = Process(target=read_file,args=(i,))
# processes.append(p)
# p.start()
# for p in processes:
# p.join()
# t2 = time.time()
# print(t2-t1)