ITADN
r-lib/fs/Issues

performance of fs::dir_exists

#500Openxtimbeau 创建于 2025-12-22
X
xtimbeaucommented
I find a huge performance gap between `fs::dir_exist()` and `base::dir.exists()`. Is there a reason for that ? Here is a reprex: ``` r fs::dir_create("test") bench::mark( base::dir.exists("test"), base::file.exists("test"), fs::dir_exists("test"), fs::file_exists("test"), check = FALSE) #> # A tibble: 4 × 6 #> expression min median `itr/sec` mem_alloc `gc/sec` #> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl> #> 1 "base::dir.exists(\"test\")" 984ns 1.07µs 911414. 0B 0 #> 2 "base::file.exists(\"test\")" 1.07µs 1.19µs 819353. 0B 0 #> 3 "fs::dir_exists(\"test\")" 398.11µs 412.95µs 2248. 1.06MB 32.1 #> 4 "fs::file_exists(\"test\")" 7.63µs 8.04µs 121029. 3.3KB 24.2 ``` <sup>Created on 2025-12-22 with [reprex v2.1.1](https://reprex.tidyverse.org)</sup>
0 条评论