jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Fastest way to loop through all DOM text nodes
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<h1><strong><em title="JavaScript">js</em>Perf</strong> — JavaScript performance playground</h1>
<h2>What is jsPerf?</h2>
<p>jsPerf aims to provide an easy way to create and share <a href="/browse" title="View some examples by browsing the jsPerf test cases">test cases</a>, comparing the performance of different JavaScript snippets by running benchmarks. For more information, see <a href="/faq" title="Frequently asked questions">the FAQ</a>.</p>
<h2>Create a test case</h2>
<h1><strong><em title="JavaScript">js</em>Perf</strong> — JavaScript performance playground</h1>
<h2>What is jsPerf?</h2>
<p>jsPerf aims to provide an easy way to create and share <a href="/browse" title="View some examples by browsing the jsPerf test cases">test cases</a>, comparing the performance of different JavaScript snippets by running benchmarks. For more information, see <a href="/faq" title="Frequently asked questions">the FAQ</a>.</p>
<h2>Create a test case</h2>
<h1><strong><em title="JavaScript">js</em>Perf</strong> — JavaScript performance playground</h1>
<h2>What is jsPerf?</h2>
<p>jsPerf aims to provide an easy way to create and share <a href="/browse" title="View some examples by browsing the jsPerf test cases">test cases</a>, comparing the performance of different JavaScript snippets by running benchmarks. For more information, see <a href="/faq" title="Frequently asked questions">the FAQ</a>.</p>
<h2>Create a test case</h2>
function LoopTextNodesA(node)
{
if (node.nodeType == 3)
{
// textnode
}
else if (node.hasChildNodes())
{
for (var i=0;i < node.childNodes.length;i++)
{
LoopTextNodesA(node.childNodes[i]);
}
}
}
function LoopTextNodesB(node)
{
if (node.nodeType == 3)
{
// textnode
}
else if (node.hasChildNodes())
{
var i = node.childNodes.length;
while(i > 0)
{
LoopTextNodesB(node.childNodes[--i]);
}
}
}
function LoopTextNodesD(node)
{
if(node)
{
node = node.firstChild;
while(node != null)
{
if(node.nodeType== 3)
{
// textnode
}
else
LoopTextNodesD(node);
node = node.nextSibling;
}
}
}
function LoopTextNodesE()
{
var walker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_TEXT,
null,
false
),
node,
textNodes = [];
while(node = walker.nextNode())
{
//textnode
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
a |
| ready |
b |
| ready |
c |
| ready |
d |
| ready |
e |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.