<html>
<body>
<div id='test'>
<div name='a'></div>
<div name='b'></div>
<div name='c'></div>
</div>
</body>
</html>
var parent = document.getElementById('test');
parent.childNodes.forEach(function (node) {
let n = node;
});
for (let i = 0; i < parent.children.length; i++) {
let n = parent.children[i];
}
let elem = parent.firstChild;
do {
let n = elem;
} while (elem = elem.nextSibling)
let elem = parent.firstElementChild;
do {
let n = elem;
} while (elem = elem.nextElementSibling)
let children = parent.childNodes;
for (let i = 0; i < children.length; i++) {
let n = children[i];
}
for (let i = parent.children.length-1; i >= 0; i--) {
let n = parent.children[i];
}
for (let i = parent.childNodes.length-1; i >= 0; i--) {
let n = parent.childNodes[i];
}
let children = parent.childNodes;
for (let i = children.length-1; i >= 0; i--) {
let n = children[i];
}
let elem = parent.lastElementChild;
do {
let n = elem;
} while (elem = elem.previousElementSibling)
let children = parent.children
for (let i = children.length-1; i >= 0; i--) {
let n = children[i];
}
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
childNodes foreach | |
children (direct) | |
firstChild nextSibling | |
firstElementChild nextElementChild | |
ChildNodes for (into variable) | |
children-- (direct) | |
ChildNodes for-- (into variable) | |
ChildNodes for-- (direct) | |
lastElementChild previousElementChild | |
children-- (into variable) |
Test name | Executions per second |
---|---|
childNodes foreach | 1870294.8 Ops/sec |
children (direct) | 2611374.2 Ops/sec |
firstChild nextSibling | 9245765.0 Ops/sec |
firstElementChild nextElementChild | 15010623.0 Ops/sec |
ChildNodes for (into variable) | 4653323.5 Ops/sec |
children-- (direct) | 4592751.5 Ops/sec |
ChildNodes for-- (into variable) | 2399889.0 Ops/sec |
ChildNodes for-- (direct) | 5971474.5 Ops/sec |
lastElementChild previousElementChild | 14791941.0 Ops/sec |
children-- (into variable) | 9820943.0 Ops/sec |
A JSON string with some data!
After removing the preamble, here's the actual data:
[
{
"RawUAString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
"Browser": "Chrome 129",
"DevicePlatform": "Desktop",
"OperatingSystem": "Mac OS X 10.15.7",
"ExecutionsPerSecond": 14791941.0,
"TestName": "lastElementChild previousElementChild"
},
{
"RawUAString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
"Browser": "Chrome 129",
"DevicePlatform": "Desktop",
"OperatingSystem": "Mac OS X 10.15.7",
"ExecutionsPerSecond": 9820943.0,
"TestName": "children-- (into variable)"
},
{
"RawUAString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
"Browser": "Chrome 129",
"DevicePlatform": "Desktop",
"OperatingSystem": "Mac OS X 10.15.7",
"ExecutionsPerSecond": 9245765.0,
"TestName": "firstChild nextSibling"
},
{
"RawUAString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
"Browser": "Chrome 129",
"DevicePlatform": "Desktop",
"OperatingSystem": "Mac OS X 10.15.7",
"ExecutionsPerSecond": 5971474.5,
"TestName": "ChildNodes for-- (direct)"
},
{
"RawUAString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
"Browser": "Chrome 129",
"DevicePlatform": "Desktop",
"OperatingSystem": "Mac OS X 10.15.7",
"ExecutionsPerSecond": 4653323.5,
"TestName": "ChildNodes for (into variable)"
},
{
"RawUAString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
"Browser": "Chrome 129",
"DevicePlatform": "Desktop",
"OperatingSystem": "Mac OS X 10.15.7",
"ExecutionsPerSecond": 4592751.5,
"TestName": "children-- (direct)"
},
{
"RawUAString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
"Browser": "Chrome 129",
"DevicePlatform": "Desktop",
"OperatingSystem": "Mac OS X 10.15.7",
"ExecutionsPerSecond": 2611374.25,
"TestName": "children (direct)"
},
{
"RawUAString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
"Browser": "Chrome 129",
"DevicePlatform": "Desktop",
"OperatingSystem": "Mac OS X 10.15.7",
"ExecutionsPerSecond": 2399889.0,
"TestName": "ChildNodes for-- (into variable)"
},
{
"RawUAString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
"Browser": "Chrome 129",
"DevicePlatform": "Desktop",
"OperatingSystem": "Mac OS X 10.15.7",
"ExecutionsPerSecond": 14791941.0,
"TestName": "lastElementChild previousElementChild"
}
]
This appears to be a list of test results, with each item in the list representing a specific test case. The fields include:
RawUAString
: the raw UA stringBrowser
: the browser nameDevicePlatform
: the device platformOperatingSystem
: the operating systemExecutionsPerSecond
: the number of executions per secondTestName
: the test namePlease let me know what you'd like to do with this data!