-
Notifications
You must be signed in to change notification settings - Fork 1
/
data.table.R
55 lines (55 loc) · 1.28 KB
/
data.table.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
48
49
50
51
52
53
54
55
library(data.table)
set.seed(108)
# mean
test1 = function(N, W) {
for (n in N) {
x = rnorm(n)
for (w in W) {
t = system.time(
ans <- frollmean(x, w)
)[["elapsed"]]
cat("data.table,mean,single,",n,",",w,",",t,"\n",sep="")
}
}
}
test4 = function(N, W) {
for (n in N) {
x = replicate(2L, rnorm(n), simplify=FALSE)
for (w in W) {
ww = w + c(-10L,10L)
t = system.time(
ans <- frollmean(x, ww)
)[["elapsed"]]
cat("data.table,mean,quadruple,",n,",",w,",",t,"\n",sep="")
}
}
}
test1(N = c(1e6, 1e7, 1e8), W = c(1e2, 1e3, 1e4))
test4(N = c(1e6, 1e7, 1e8), W = c(1e2, 1e3, 1e4))
# median
test1 = function(N, W) {
for (n in N) {
x = rnorm(n)
for (w in W) {
t = system.time(
ans <- frollmedian(x, w)
)[["elapsed"]]
cat("data.table,median,single,",n,",",w,",",t,"\n",sep="")
}
}
}
test4 = function(N, W) {
for (n in N) {
x = replicate(2L, rnorm(n), simplify=FALSE)
for (w in W) {
ww = w + c(-10L,10L)
t = system.time(
ans <- frollmedian(x, ww)
)[["elapsed"]]
cat("data.table,median,quadruple,",n,",",w,",",t,"\n",sep="")
}
}
}
test1(N = c(1e6, 1e7, 1e8), W = c(1e2, 1e3, 1e4))
test4(N = c(1e6, 1e7, 1e8), W = c(1e2, 1e3, 1e4))
q(status=0)