Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Unify filtering by selector in `winnow` #3272
Comments
gibson042
added
the
Traversing
label
Aug 11, 2016
gibson042
referenced this issue
Aug 11, 2016
Closed
Traversing: Let .not(arraylike) pass non-element nodes #3261
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
gibson042
Aug 12, 2016
Member
Poor man's jsPerf benchmark: https://jsfiddle.net/uo2j7syk/
Typical run:
# {method}_{selector complexity}_{implementation}
find_simple_master: 1,125 ±2% (1,105–1,145) ops/sec
find_simple_direct: 1,140 ±2% (1,122–1,157) ops/sec
find_simple_intersect: 190 ±2% (186–193) ops/sec
not_simple_master: 524 ±2% (515–532) ops/sec
not_simple_direct: 529 ±2% (521–537) ops/sec
not_simple_intersect: 180 ±2% (177–183) ops/sec
find_complex_master: 483 ±2% (476–491) ops/sec
find_complex_direct: 743 ±1% (732–754) ops/sec
find_complex_intersect: 477 ±2% (470–485) ops/sec
not_complex_master: 440 ±2% (433–447) ops/sec
not_complex_direct: 393 ±2% (386–399) ops/sec
not_complex_intersect: 441 ±2% (433–449) ops/secThe current code is taking a huge performance hit vs. always using only jQuery.filter( qualifier, elements, not ) for .find(nonSimple), but is noticeably faster for .not(nonSimple) (albeit by a smaller margin). I'm still in favor of completely dropping the set-intersection branch, but a case could be made for restricting it to the latter cases. Thoughts, @jquery/core?
|
Poor man's jsPerf benchmark: https://jsfiddle.net/uo2j7syk/ # {method}_{selector complexity}_{implementation}
find_simple_master: 1,125 ±2% (1,105–1,145) ops/sec
find_simple_direct: 1,140 ±2% (1,122–1,157) ops/sec
find_simple_intersect: 190 ±2% (186–193) ops/sec
not_simple_master: 524 ±2% (515–532) ops/sec
not_simple_direct: 529 ±2% (521–537) ops/sec
not_simple_intersect: 180 ±2% (177–183) ops/sec
find_complex_master: 483 ±2% (476–491) ops/sec
find_complex_direct: 743 ±1% (732–754) ops/sec
find_complex_intersect: 477 ±2% (470–485) ops/sec
not_complex_master: 440 ±2% (433–447) ops/sec
not_complex_direct: 393 ±2% (386–399) ops/sec
not_complex_intersect: 441 ±2% (433–449) ops/secThe current code is taking a huge performance hit vs. always using only |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment|
Nice benchmark! I still like the idea of simplifying the code as well. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment|
+1 for simplifying |
gibson042 commentedAug 11, 2016
Per https://github.com/jquery/jquery/pull/3261/files/c1339665c27440a23a5576ca1dfdad9c38567288#r74370245 , the complexity of separate branches for simple vs. non-simple selectors doesn't seem worthwhile. Both of them should defer directly to
jQuery.filter.