Skip to content

Instantly share code, notes, and snippets.

@kanishkamisra
Created August 26, 2018 21:23
Show Gist options
  • Save kanishkamisra/3eb81f55b96c8d7d201179668efa9b99 to your computer and use it in GitHub Desktop.
Save kanishkamisra/3eb81f55b96c8d7d201179668efa9b99 to your computer and use it in GitHub Desktop.
tracemem experiment for dplyr
library(lobstr)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(reprex)
x <- mtcars
obj_size(x)
#> 6,736 B
tracemem(x)
#> [1] "<0x1daa4d8>"
x %>%
filter(disp > 160) %>%
mutate(greater_200 = disp > 200)
#> tracemem[0x1daa4d8 -> 0x12c2e68]: list_to_tibble as_data_frame.data.frame as_data_frame tbl_df filter as.data.frame filter.data.frame filter <Anonymous> freduce _fseq eval eval withVisible %>% eval eval withVisible withCallingHandlers doTryCatch tryCatchOne tryCatchList tryCatch try handle timing_fn evaluate_call <Anonymous> evaluate in_dir block_exec call_block process_group.block process_group withCallingHandlers process_file <Anonymous> <Anonymous> <Anonymous> <Anonymous> do.call saveRDS withCallingHandlers
#> tracemem[0x12c2e68 -> 0x3640918]: check_tibble list_to_tibble as_data_frame.data.frame as_data_frame tbl_df filter as.data.frame filter.data.frame filter <Anonymous> freduce _fseq eval eval withVisible %>% eval eval withVisible withCallingHandlers doTryCatch tryCatchOne tryCatchList tryCatch try handle timing_fn evaluate_call <Anonymous> evaluate in_dir block_exec call_block process_group.block process_group withCallingHandlers process_file <Anonymous> <Anonymous> <Anonymous> <Anonymous> do.call saveRDS withCallingHandlers
#> tracemem[0x3640918 -> 0x340e1f8]: new_tibble list_to_tibble as_data_frame.data.frame as_data_frame tbl_df filter as.data.frame filter.data.frame filter <Anonymous> freduce _fseq eval eval withVisible %>% eval eval withVisible withCallingHandlers doTryCatch tryCatchOne tryCatchList tryCatch try handle timing_fn evaluate_call <Anonymous> evaluate in_dir block_exec call_block process_group.block process_group withCallingHandlers process_file <Anonymous> <Anonymous> <Anonymous> <Anonymous> do.call saveRDS withCallingHandlers
#> tracemem[0x340e1f8 -> 0x2f30be8]: set_tibble_class new_tibble list_to_tibble as_data_frame.data.frame as_data_frame tbl_df filter as.data.frame filter.data.frame filter <Anonymous> freduce _fseq eval eval withVisible %>% eval eval withVisible withCallingHandlers doTryCatch tryCatchOne tryCatchList tryCatch try handle timing_fn evaluate_call <Anonymous> evaluate in_dir block_exec call_block process_group.block process_group withCallingHandlers process_file <Anonymous> <Anonymous> <Anonymous> <Anonymous> do.call saveRDS withCallingHandlers
#> tracemem[0x2f30be8 -> 0x2f312c8]: as_data_frame.data.frame as_data_frame tbl_df filter as.data.frame filter.data.frame filter <Anonymous> freduce _fseq eval eval withVisible %>% eval eval withVisible withCallingHandlers doTryCatch tryCatchOne tryCatchList tryCatch try handle timing_fn evaluate_call <Anonymous> evaluate in_dir block_exec call_block process_group.block process_group withCallingHandlers process_file <Anonymous> <Anonymous> <Anonymous> <Anonymous> do.call saveRDS withCallingHandlers
#> mpg cyl disp hp drat wt qsec vs am gear carb greater_200
#> 1 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1 TRUE
#> 2 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2 TRUE
#> 3 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1 TRUE
#> 4 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4 TRUE
#> 5 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4 FALSE
#> 6 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4 FALSE
#> 7 16.4 8 275.8 180 3.07 4.070 17.40 0 0 3 3 TRUE
#> 8 17.3 8 275.8 180 3.07 3.730 17.60 0 0 3 3 TRUE
#> 9 15.2 8 275.8 180 3.07 3.780 18.00 0 0 3 3 TRUE
#> 10 10.4 8 472.0 205 2.93 5.250 17.98 0 0 3 4 TRUE
#> 11 10.4 8 460.0 215 3.00 5.424 17.82 0 0 3 4 TRUE
#> 12 14.7 8 440.0 230 3.23 5.345 17.42 0 0 3 4 TRUE
#> 13 15.5 8 318.0 150 2.76 3.520 16.87 0 0 3 2 TRUE
#> 14 15.2 8 304.0 150 3.15 3.435 17.30 0 0 3 2 TRUE
#> 15 13.3 8 350.0 245 3.73 3.840 15.41 0 0 3 4 TRUE
#> 16 19.2 8 400.0 175 3.08 3.845 17.05 0 0 3 2 TRUE
#> 17 15.8 8 351.0 264 4.22 3.170 14.50 0 1 5 4 TRUE
#> 18 15.0 8 301.0 335 3.54 3.570 14.60 0 1 5 8 TRUE
obj_size(x)
#> 6,736 B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment