For example on this page https://en.wikipedia.org/wiki/Earth you would want to get first 4 title names.
old way - document.querySelectorAll('.mw-headline').take(4).toList(); would take BenchHtml(RunTime): 81102.96 us.
new way - document.querySelectorAll('.mw-headline', limit: 4); - would take BenchHtmlLimit(RunTime): 7417.951851851852 us. (~10x times less)
If you want only a first few results then having
limit
parameter is significantly faster than iterating wastefully the whole tree.I've created a quick example with benchmark https://github.com/mzdm/dart_html_limit_perf_test
For example on this page https://en.wikipedia.org/wiki/Earth you would want to get first 4 title names. old way -
document.querySelectorAll('.mw-headline').take(4).toList();
would take BenchHtml(RunTime): 81102.96 us. new way -document.querySelectorAll('.mw-headline', limit: 4);
- would take BenchHtmlLimit(RunTime): 7417.951851851852 us. (~10x times less)If this is OK approach then I can add some tests.