Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
While loop vs Closest
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0
Browser:
Firefox 132
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
while
58675.0 Ops/sec
closest
84209.0 Ops/sec
HTML Preparation code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <style type="text/css"> .hidden { display: none; } </style> <div class="visible"> <div class="hidden"> <div class="hidden"> <div class="hidden hidden-last"></div> </div> </div> </div> <script> Benchmark.prototype.setup = function() { var $element = $('.hidden-last'); }; </script>
Tests:
while
while ($element.is(":hidden")) { $element = $element.parent(); }
closest
$element = $element.closest(':visible')