-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoftware_speed.R
47 lines (37 loc) · 1.17 KB
/
software_speed.R
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
# speed test
# import required packages
#install.packages("nonlinearTseries")
#install.packages("crqa")
#install.packages("abind")
#install.packages("tictoc")
require(stats)
library(tictoc)
library(nonlinearTseries)
library(crqa)
library(abind)
# solve the Roessler ODE
r = rossler(time=seq(0,4500,by = 0.05));
x = r$x
# length of time series for RQA calculation test
N = round(10.^seq(2.3,5.06, 0.075))
# calculate RP and RQA for different length
tspan = numeric(length(N)) # result vector computation time
K = 10 # number of runs (for averaging time)
maxT = 60 # stop calculations if maxT is exceeded
for (i in 1:length(N)) {
t_ = 0
for (j in 1:K) {
start_time <- Sys.time()
R <- crqa(x[1000:(1000+N[i]-1)], x[1000:(1000+N[i]-1)], 3, 6, 0, 1.2, 0, 2, 2, 0, FALSE, FALSE, 'both', 'rqa','euclidean', 'continuous')
t_ <- t_ + as.numeric(Sys.time() - start_time)
cat(" ", j, "\n")
}
tspan[i] <- t_ / K # average calculation time
cat(N[i], ": ", tspan[i], "\n")
if (tspan[i] >= maxT) {
break
}
}
print(tspan)
ex = abind(N, tspan, along=2)
write.table(ex, file = "time_R.csv", col.names=FALSE, row.names=FALSE)