Skip to content

add built-in query object caching for reuse in the multiple queries with the same query string #16

Closed

Description

@zhengchun

htmlquery provides new methods QuerySelector and QuerySelectorAll, We can use compiled query object to reuse and avoid recompile the XPath query expression, this will shorter query speed time and improve application performance.

Activity

  1. subsr97 commented on Oct 27, 2019

    @subsr97
    Contributor

    @zhengchun
    As I understand, you're suggesting to cache compiled XPath query expressions for use by FindOne and Find methods.

    But wouldn't the overhead of maintaining a cache be greater than the overhead caused by recompiling XPath queries?

  2. zhengchun commented on Oct 31, 2019

    @zhengchun
    ContributorAuthor

    In fact, caching frequently used query objects can improve query performance. groupcache, I just caching Top N objects those the most frequent query object.

  3. zhengchun commented on Nov 9, 2019

    @zhengchun
    ContributorAuthor

    https://github.com/antchfx/htmlquery/blob/master/query_test.go#L47

    goos: windows
    goarch: amd64
    pkg: github.com/antchfx/htmlquery
    BenchmarkSelectorCache-4                20000000                55.2 ns/op
    BenchmarkDisableSelectorCache-4           500000              3162 ns/op
    PASS
    
  4. zhengchun commented on Nov 11, 2019

    @zhengchun
    ContributorAuthor

    # Add XPath selector object caching feature 14e3905

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址