-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
71 lines (58 loc) · 1.98 KB
/
main.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import os
import pickle
from case1 import ELT_row_by_row
from case2 import file_to_db
from case3 import multiprocess_pipeline
from createdb import create_db
import time
from matplotlib import pyplot as plt
import numpy as np
os.makedirs('Databases/old_databases')
os.makedirs('Databases/new_databases')
os.makedirs('Databases/files')
f = open("case1.pickle","wb")
g = open("case2.pickle","wb")
h = open("case3.pickle","wb")
data1,data2,data3 = {},{},{}
for i in range(1,11):
create_db(f"./Databases/old_databases/database{i}.db",100*i)
## Create Dictionary for Case1 :
for i in range(1,11):
start = time.time()
ELT_row_by_row(f'./Databases/old_databases/database{i}.db',f'./Databases/new_databases/database{i}.db')
end = time.time()
data1[str(i*100) + ' Records'] = end - start
pickle.dump(data1,f)
for file in os.listdir('./Databases/new_databases'):
os.remove(f'./Databases/new_databases/{file}')
## Create Dictionary for Case2:
for i in range(1,11):
start = time.time()
file_to_db(f'./Databases/old_databases/database{i}.db',f'./Databases/new_databases/database{i}.db',f'./Databases/files/file{i}.csv')
end = time.time()
data2[str(i*100) + ' Records'] = end - start
pickle.dump(data2,g)
for file in os.listdir('./Databases/new_databases'):
os.remove(f'./Databases/new_databases/{file}')
for i in range(1,11):
check = multiprocess_pipeline(f'./Databases/old_databases/database{i}.db',f'./Databases/new_databases/database{i}.db')
data3[str(i*100) + ' Records'] = check
pickle.dump(data3,h)
f.close()
g.close()
h.close()
f = open("case1.pickle","rb")
g = open("case2.pickle","rb")
h = open("case3.pickle","rb")
data1 = pickle.load(f)
data2 = pickle.load(g)
data3 = pickle.load(h)
x = np.arange(1, 11, 1)
plt.plot(data1.values(),label="Case 1")
plt.plot(data2.values(),label = "Case 2")
plt.plot(data3.values(),label= "Case 3")
plt.xticks(x)
plt.xlabel("No. of Records (per 1000)")
plt.ylabel("Time Taken in Seconds")
plt.legend()
plt.savefig('result.png')