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 (X11; Ubuntu; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0
Browser:
Firefox 130
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
while
280724.2 Ops/sec
closest
333675.2 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')