Skip to content

Some operations are much slower than base #295

@wch

Description

@wch

For example:

library(fs)
system.time({
  for (i in 1:1000) file_exists('DESCRIPTION')
})
#>    user  system elapsed 
#>   0.523   0.016   0.539

system.time({
  for (i in 1:1000) file.exists('DESCRIPTION')
})
#>    user  system elapsed 
#>   0.002   0.001   0.003

Similarly, replacing an instance of dir_copy with equivalent base code results in a significant speedup. For this test, the time spent in the copying code went from 370ms to 10ms. This is a real-world case where the speed impact is noticeable. rstudio/sass#53

It is harder to get the code right with base functions, so it would be nice to use fs.

Sorry this isn't more specific about exactly which operations are slow. However, when I profiled it, it looked like a lot of time for file_exists was spent dealing with tibbles. (Note that it had to be profiled on R 3.6, since the profiler in R 4.0 has a bug and doesn't generate useful data.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions