Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuerySelectorAll - performance #584

Closed
jirisykora83 opened this issue Jul 10, 2017 · 6 comments · Fixed by #1134
Closed

QuerySelectorAll - performance #584

jirisykora83 opened this issue Jul 10, 2017 · 6 comments · Fixed by #1134

Comments

@jirisykora83
Copy link

jirisykora83 commented Jul 10, 2017

I try to profile my app because i facing issue with performance (main reason why i recently switch from HAP). And i notice NodeList.get_Length() in QuerySelectorAll is take lot of time (almost 10%). Of course it depend on how much elements is in collection).

I want to try rewrite it with my custom QuerySelectorAll but i end with too many class is need to rewrite. Maybe you can try just save elements.Length to local variable it should get some percent of performance in this highly used function.

image

Testing with last stable version 0.9.9 but from first look at dev branch i think it is same in 0.1.0.
VS 2017 - release mode of course

@FlorianRappl
Copy link
Contributor

I think caching one or the other thing may indeed be useful.

Caching elements.Length sounds like a small / notable gain without any side-effects or risks - thanks for the suggestion!

@campersau
Copy link
Contributor

An example to reproduce your results would be helpful. Used HTML and CSS selectors.

@jirisykora83
Copy link
Author

Sorry for late response i have short vacation.

Here is simplify version of my testing scenario (in my testing scenario i also extract some data but
i call QuerySelectorAll just on one other place).

For benchmark i use BenchmarkDotNet.

Example:
AngleSharpBenchmark.zip

@FlorianRappl
Copy link
Contributor

Would be simpler to have a Gist.

@jirisykora83
Copy link
Author

@FlorianRappl
Copy link
Contributor

Great, thanks!

@FlorianRappl FlorianRappl added this to the v0.10 milestone Jan 4, 2018
@FlorianRappl FlorianRappl modified the milestones: v0.10, v1.0 Dec 3, 2018
@FlorianRappl FlorianRappl modified the milestones: v0.15, v1.0 Apr 22, 2021
@FlorianRappl FlorianRappl modified the milestones: v1.0, vNext Jan 7, 2023
FlorianRappl added a commit that referenced this issue Aug 20, 2023
Improve QuerySelectorAll performance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants