Created
October 24, 2017 09:24
-
-
Save frbl/ef64fe8d5c935ddf9af7fddecf01a600 to your computer and use it in GitHub Desktop.
Difference between rbind and rbindlist in terms of time, for appending a single row
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(microbenchmark) | |
library(data.table) | |
rbindlist_time <- function() { | |
data <- data.table(a=c(1),b=c(2)) | |
for (item in 1:10000) { | |
data <- rbindlist(data, data.table(a=c(1),b=c(2))) | |
} | |
} | |
rbind_time <- function() { | |
data <- data.table(a=c(1),b=c(2)) | |
for (item in 1:10000) { | |
data <- rbind(data, data.table(a=c(1),b=c(2))) | |
} | |
} | |
microbenchmark( | |
rbindlist_time, | |
rbind_time | |
) | |
#Unit: nanoseconds | |
# expr min lq mean median uq max neval | |
# rbindlist_time 21 22 30.09 23 23 738 100 | |
# rbind_time 22 23 29.93 24 25 547 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment