Skip to content

Conversation

ziluvatar
Copy link

I identified 2 performance degradations:

  • When a copy of a XPathContext is needed, new XPathContext() is created, which creates new resolvers for it, afterwards those are discarded and in favor of the context to be copied from. Out of these resolvers FunctionResolver creation was particularly more expensive than he others.
  • Individual checks for assigning fields in assign() function added performance overhead.

The solution I found for both was to:

  • Create a shallow cloning function (removing extend, I could leave it in code, unused, to keep public compatibility if needed), passing the available resolvers to the new context, which avoids the waste of their creation.
  • Manually assign the available fields in a context.

I added also the benchmark code I used for this, which provides this information:

  • For current 0.0.34: Benchmark completed in 4612.00 milliseconds for 100000 iterations.
  • For code in the PR: Benchmark completed in 1444.20 milliseconds for 100000 iterations. (3x times faster)

I can remove the benchmark file if needed, I thought it would be useful for future.

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.

1 participant