-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
Hi,
I am using graalvm and fastr rc-15. I was testing the tidyr
package in fastr. I got no errors using the functions I want to use. But I did found it extremely slow. I use the function unnest
from the tidyr
package to split a data.frame on a list column.
For example, I made this file (let's call it tidyr_unnest.R
):
library(pdftools)
library(glue)
library(tidyr)
library(tictoc)
# A lot of code to get an object to test performance on
img <- pdf_render_page(pdf = "https://cran.r-project.org/web/packages/purrr/purrr.pdf", page = 1)
dimension <- dim(img)
img_glued <- glue('#{img[1, 1:dimension[2], 1:dimension[3]]}{img[2, 1:dimension[2], 1:dimension[3]]}{img[3, 1:dimension[2], 1:dimension[3]]}{img[4, 1:dimension[2], 1:dimension[3]]}')
img_mat <- matrix(img_glued, nrow = dimension[2], ncol = dimension[3])
img_mat_not_white <- img_mat!="#ffffffff"
l <- dim(img_mat_not_white)[1]
list_y <- data.frame(y = rep(NA_integer_, l), stringsAsFactors = FALSE)
list_y$x <- list(NA_integer_)
for(i in 1:l){
x <- which(img_mat_not_white[i,])
if(length(x) > 0){
list_y$y[i] <- i
list_y$x[i] <- list(x)
}
}
list_y <- list_y[!is.na(list_y$y),]
list_y$Freq <- sapply(list_y$x, length)
list_y$split <- lapply(list_y$x, function(y){
split(y, cumsum(diff(c(0, y)) > 1))
})
tic("Unnest nested lists (using tidyr::unnest)")
unnest_list_y <- unnest(list_y, split)
toc()
Sourcing the files in R and fastR (source("tidyr_unnest.R")
) gives me:
# R
Unnest nested lists (using tidyr::unnest): 0.021 sec elapsed
# fastR
Unnest nested lists (using tidyr::unnest): 3.925 sec elapsed
Do you know what is happening? Thanks in advance and for developing fastR!
NRBPerdijk, jhkuperus and jGinkel
Metadata
Metadata
Assignees
Labels
No labels