Skip to content

Instantly share code, notes, and snippets.

@DavisVaughan
Created June 10, 2021 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavisVaughan/19ff12010ff9ad17214627bb4d2d0729 to your computer and use it in GitHub Desktop.
Save DavisVaughan/19ff12010ff9ad17214627bb4d2d0729 to your computer and use it in GitHub Desktop.
@DavisVaughan
Copy link
Author

library(rsample)
library(modeldata)
data(wa_churn)

df <- bootstraps(wa_churn, 100)

# Look, recipes is smart! This is cheap
lobstr::obj_size(df)
#> 3,667,368 B

# This is the approximate cost of 100 bootstraps if we weren't being smart
lobstr::obj_size(wa_churn) * 100
#> 76,774,400 B

# Mock sending it off to a PSOCK worker and reading it back in on that worker
tf <- tempfile()
saveRDS(df, tf)
df_read <- readRDS(tf)

# Now we are around that approximate cost, because each of the 100 data frames gets fully copied
lobstr::obj_size(df_read)
#> 79,430,088 B

Created on 2021-06-10 by the reprex package (v2.0.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment