parent children vs siblings and self (v3)

Revision 3 of this benchmark created on


Description

To get the list of all items at the level of a certain element, is it faster to do .parent().children() or .siblings().andSelf()?

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<div>

    <p></p>
    <p></p>

    <p></p>
    <p></p>
    <p></p>
    <p id="someElement"></p>
 
</div>

Setup

var $someElement = $("#someElement"),
        someElement = $someElement[0];

Test runner

Ready to run.

Testing in
TestOps/sec
parent's children
var $els = $someElement.parent().children();
ready
siblings and self
var $els = $someElement.siblings().andSelf();
ready
parentNode and children
var $els = $(someElement.parentNode).children();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.