| 1 |
library("profmem") |
| 2 |
|
| 3 |
message("profmem() - nested ...") |
| 4 |
|
| 5 |
if (capabilities("profmem")) { |
| 6 |
|
| 7 |
p1 <- profmem({ |
| 8 |
x <- integer(1000) |
| 9 |
p2 <- profmem({ |
| 10 |
Y <- matrix(x, nrow = 100, ncol = 10) |
| 11 |
}) |
| 12 |
z <- Y + (x + 1) |
| 13 |
}) |
| 14 |
print(p1) |
| 15 |
print(p2) |
| 16 |
|
| 17 |
p1 <- profmem({ |
| 18 |
x <- integer(1000) |
| 19 |
p2 <- profmem({ |
| 20 |
Y <- matrix(x, nrow = 100, ncol = 10) |
| 21 |
}) |
| 22 |
z <- Y + (x + 1) |
| 23 |
}, threshold = 500L) |
| 24 |
print(p1) |
| 25 |
print(p2) |
| 26 |
|
| 27 |
## Cannot set a higher threshold than already active |
| 28 |
p1 <- profmem({ p2 <- profmem({ }, threshold = 1000L) }) |
| 29 |
|
| 30 |
p1 <- profmem({ |
| 31 |
## Cannot set a higher threshold than already active |
| 32 |
res <- tryCatch({ |
| 33 |
p2 <- profmem({ }, threshold = 1000L) |
| 34 |
}, warning = identify) |
| 35 |
stopifnot(inherits(res, "warning")) |
| 36 |
}) |
| 37 |
print(p1) |
| 38 |
print(p2) |
| 39 |
|
| 40 |
} |
| 41 |
|
| 42 |
message("profmem() - nested ... DONE") |