Guest User

Untitled

a guest
May 6th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. library(devtools)
  2. # install_github("wesm/feather/R")
  3. library(feather)
  4. library(microbenchmark)
  5.  
  6. set.seed(3-29-16)
  7.  
  8. rows <- 100000
  9.  
  10. x <- data.frame(ints = round(runif(rows, -100, 100)), stringsAsFactors = FALSE)
  11. x$floats <- runif(rows, -100, 100)
  12. x$bools <- sample(c(TRUE, FALSE), rows, replace = TRUE)
  13. x$dates <- as.POSIXct(runif(rows, 100000000, 1459293171), origin = "1970-01-01")
  14. x$categories <- as.factor(sample(c(LETTERS, 0:9), rows, replace = TRUE))
  15. x$strings <- replicate(rows, paste0(sample(letters, sample(1:10, 1), replace = TRUE), collapse = ""))
  16.  
  17. microbenchmark(
  18. write.csv(x, file = "x.csv"), times = 10
  19. )
  20.  
  21. microbenchmark(
  22. save(x, file = "x.rda"), times = 10
  23. )
  24.  
  25. microbenchmark(
  26. saveRDS(x, file = "x.rds"), times = 10
  27. )
  28.  
  29. microbenchmark(
  30. write_feather(x, "x.feather"), times = 10
  31. )
  32.  
  33. rm(x, rows)
  34.  
  35. file.size("x.csv")
  36.  
  37. file.size("x.rda")
  38.  
  39. file.size("x.rds")
  40.  
  41. file.size("x.feather")
  42.  
  43. microbenchmark(
  44. y <- read.csv("x.csv"), times = 10
  45. )
  46.  
  47. rm(y)
  48.  
  49. microbenchmark(
  50. load("x.rda"), times = 10
  51. )
  52.  
  53. rm(x)
  54.  
  55. microbenchmark(
  56. y <- readRDS("x.rds"), times = 10
  57. )
  58.  
  59. rm(y)
  60.  
  61. microbenchmark(
  62. y <- read_feather("x.feather"), times = 10
  63. )
  64.  
  65.  
  66.  
  67. session_info()
Add Comment
Please, Sign In to add comment