-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
35 lines (33 loc) · 908 Bytes
/
test.py
File metadata and controls
35 lines (33 loc) · 908 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
import scipy.io as sio
from toppush import topPush as topPush
from toppush import topPush as topPushWithC
import numpy as np
import time
if __name__ == '__main__':
data = sio.loadmat("spambase.mat")
x = data['Xtr']
y = data['ytr']
xte = data['Xte'].toarray()
ans = data['ans']
x = np.array(x.toarray())
y = np.array(y)
# warm up
for i in range(10):
w = topPush(x, y)
# test toppush
begin = time.time_ns()
for i in range(10):
w = topPush(x, y)
end = time.time_ns()
topPushTime = end - begin
# warm up
for i in range(10):
w = topPushWithC(x, y)
# test toppushWithC
begin = time.time_ns()
for i in range(10):
w = topPushWithC(x, y)
end = time.time_ns()
topPushWithCTime = end - begin
print(f"topPush time: {topPushTime / 1e9} s")
print(f"topPushWithC time: {topPushWithCTime / 1e9} s")