+
Skip to content

Conversation

mgirlich
Copy link
Contributor

@mgirlich mgirlich commented Jun 1, 2023

This gives a small performance improvement, e.g. for xml_find_all(flatten = TRUE)

library(xml2)

path <- xml2_example("cd_catalog.xml")
xml <- read_xml(path)
cds <- xml_find_all(xml, "CD")

find <- function() {
  xml_find_all(cds, "TITLE", flatten = FALSE)
}

bench::mark(
  find()
)

# Before
#> # A tibble: 1 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 find()        400µs    428µs     2165.    30.3KB     10.3

# After
#> # A tibble: 1 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 find()        324µs    360µs     2529.    30.3KB     8.20

Created on 2023-06-01 with reprex v2.0.2

This helps towards #394.

@hadley hadley merged commit f251e92 into r-lib:main Jun 29, 2023
@hadley
Copy link
Member

hadley commented Jun 29, 2023

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载