-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_speed.m
88 lines (77 loc) · 944 Bytes
/
test_speed.m
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
%%
num=1e6;
em=(1:4);
emc=num2cell(em);
tic;
for i_n=1:num
[a,b,c,d]=emc{1,:};
end
toc;
tic;
for i_n=1:num
a=em(1,1);
b=em(1,2);
c=em(1,3);
d=em(1,4);
end
toc;
%%
tic;
n_layer=200;
for i_n=1:num
E=NaN*ones(n_layer,16);
E_inv=E;
Lambda_inv=E(:,1:4);
end
toc;
tic;
n_layer=200;
for i_n=1:num
E=NaN*ones(n_layer,16);
E_inv=NaN*ones(n_layer,16);
Lambda_inv=NaN*ones(n_layer,4);
end
toc;
tic;
n_layer=200;
for i_n=1:num
E=NaN*ones(n_layer,16);
E_inv=E;
Lambda_inv=NaN*ones(n_layer,4);
end
toc;
tic;
n_layer=200;
for i_n=1:num
E=zeros(n_layer,16);
E_inv=E;
Lambda_inv=zeros(n_layer,4);
end
toc;
%%
num=2e4;
tic;
for i_n=1:num
E=gen_E(1,0.1,2,5,3);
E_inv=inv(E);
end
toc;
tic;
for i_n=1:num
E=gen_E(1,0.1,2,5,3);
E_inv=gen_E_inv(1,0.1,2,5,3);
end
toc;
%%
num=1e7;
a=rand(10);
tic;
for i_n=1:num
b=a*10;
end
toc;
tic;
for i_n=1:num
b=a.*10;
end
toc;