-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathbench-conv2.Rmd
61 lines (51 loc) · 1.59 KB
/
bench-conv2.Rmd
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
---
title: "Benchmark conv after changes"
author: "Florian Privé"
date: "September 9, 2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
unlink(list.files(tempdir(), pattern = "\\.bk$", full.names = TRUE))
options(width = 110)
```
```{r, warning=FALSE}
library(bigstatsr)
library(foreach)
N <- M <- 2000
x4 <- matrix(round(rnorm(N * M, 100, 10)), N)
x3 <- x2 <- x1 <- x4
storage.mode(x1) <- "raw"
storage.mode(x2) <- "logical"
storage.mode(x3) <- "integer"
X5 <- big_copy(x4, type = "double")
X4 <- big_copy(x4, type = "float")
X3 <- big_copy(x4, type = "integer")
X2 <- big_copy(x4, type = "unsigned short")
X1 <- big_copy(x4, type = "unsigned char")
options(bigstatsr.downcast.warning = FALSE)
foreach(X = list(X1, X2, X3, X4, X5)) %:%
foreach(x = list(x1, x2, x3, x4), .combine = "c") %do% {
tmp <- microbenchmark::microbenchmark(X[] <- x)
round(median(tmp$time) / 1e6)
}
options(bigstatsr.downcast.warning = TRUE)
foreach(X = list(X1, X2, X3, X4, X5)) %:%
foreach(x = list(x1, x2, x3, x4), .combine = "c") %do% {
tmp <- microbenchmark::microbenchmark(X[] <- x)
round(median(tmp$time) / 1e6)
}
```
```{r, warning=FALSE}
library(bigmemory)
Y5 <- as.big.matrix(x4, type = "double")
Y4 <- as.big.matrix(x4, type = "float")
Y3 <- as.big.matrix(x4, type = "integer")
Y2 <- as.big.matrix(x4, type = "short")
Y1 <- as.big.matrix(x4, type = "char")
foreach(X = list(Y1, Y2, Y3, Y4, Y5)) %:%
foreach(x = list(x1, x2, x3, x4), .combine = "c") %do% {
tmp <- microbenchmark::microbenchmark(X[] <- x, times = 10)
round(median(tmp$time) / 1e6)
}
```