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
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="clicker">
stuff
<span>
something
<span>
else
</span>
</span>
<a href="http://www.google.com">link!</a>
</div>
<script>
var constants = {
color: 'color',
red: 'red',
span: 'span',
blue: 'blue',
link: 'a',
clicker: '#clicker'
};
var outerVar = null;
var tests = {
recreating: function() {
$(this).css("color", "red");
$(this).find("span").css("color", "blue");
$(this).find("a").css("color", $(this).css("color"));
},
variable: function() {
var $this = $(this);
$this.css("color", "red");
$this.find("span").css("color", "blue");
$this.find("a").css("color", $this.css("color"));
},
chaining: function() {
$(this).css("color", "red").find("span").css("color", "blue").end().find("a").css("color", $(this).css("color"));
},
lessChaining: function() {
$(this).css("color", "red").find("span").css("color", "blue");
$(this).find("a").css("color", $(this).css("color"));
},
outerVar: function() {
outerVar = $(this);
outerVar.css("color", "red");
outerVar.find("span").css("color", "blue");
outerVar.find("a").css("color", outerVar.css("color"));
outerVar = null;
},
constantRecreate: function() {
$(this).css(constants.color, constants.red);
$(this).find(constants.span).css(constants.color, constants.blue);
$(this).find(constants.link).css(constants.color, $(this).css(constants.color));
},
constantOuterVar: function() {
outerVar = $(this);
outerVar.css(constants.color, constants.red);
outerVar.find(constants.span).css(constants.color, constants.blue);
outerVar.find(constants.link).css(constants.color, outerVar.css(constants.color));
},
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
recreating |
| ready |
variable |
| ready |
chaining |
| ready |
outer var |
| ready |
constants recreate |
| ready |
constants variable |
| ready |
less chaining |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.