-
Notifications
You must be signed in to change notification settings - Fork 0
/
software_speed.m
70 lines (52 loc) · 1.87 KB
/
software_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
%% speed test
%% enable rp tools
% first clone from https://github.com/pucicu/rp to subfolder rp before you can use it
addpath('./rp')
%% the Roessler ODE
r = @(t,x) [-(x(2) + x(3));
x(1) + 0.25 * x(2);
0.25 + (x(1) - 4) * x(3)];
%% solve the ODE
options = odeset('RelTol',1e-8,'AbsTol',1e-10);
[t x] = ode45(r,[0:0.05:2500],[0;0;0]);
%% skip first 1000 points
t(1:1000) = []; x(1:1000,:) = [];
%% length of time series for RQA calculation test
N = round(10.^(2:.075:5.06));
%% calculate RP and RQA for different length
tspanRP = zeros(length(N), 1); % result vector computation time
tspanRQA = zeros(length(N), 1); % result vector computation time
K = 10; % number of runs (for averaging time)
maxT = 60; % stop calculations if maxT is exceeded
% % using CRP toolbox (slow because of GUI framework)
% for i = 1:length(N)
% tic
% %R = crp(x(1:1+N(i)-1,3), 3, 6, 1.2, 'euc', 'nonorm','silent');
% Q = crqa(x(1:1+N(i)-1,3), 3, 6, 1.2, [], 'euc', 'nonorm','silent');
% tspan(i) = toc;
% end
% tspan
for i = 1:length(N)
tRP_ = 0;
tRQA_ = 0;
xe = embed(x(1:1+N(i)-1,1), 3, 6);
for j = 1:K
%R = squareform(pdist(xe) <= 1.2);
tic
R = rp(xe, 1.2, 'fix', 'euc', 'matlabvector'); % a bit slower than previous line because of some testing expressions
tRP_ = tRP_ + toc;
tic
Q = rqa(R, 2, 1, 'non');
tRQA_ = tRQA_ + toc;
disp(sprintf(' %i', j))
end
tspanRP(i) = tRP_ / K; % average calculation time
tspanRQA(i) = tRQA_ / K; % average calculation time
disp(sprintf('%i: %f %f', N(i), tspanRP(i), tspanRQA(i)))
if tspanRP(i) + tspanRQA(i) >= maxT, break, end
end
N(1:4) = []; tspanRP(1:4) = []; tspanRQA(1:4) = [];% remove first points before N=200
tspanRP
ex = [N(:) tspanRP(:) tspanRQA(:)];
save time_matlab_vector.csv ex -ascii -tabs
exit