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="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>
<script>
var Y = YUI().use('yui-throttle', function (Y) {
Y.newThrottle = function (fn, duration, context) {
var lastTime = 0,
lastArgs, timeout;
duration || (duration = Y.config.throttleTime || 150);
function execute() {
var args = lastArgs;
lastArgs = null;
lastTime = Y.Lang.now();
timeout = null;
fn.apply(context, args);
}
return function () {
var now;
lastArgs = arguments;
if (timeout) { return; }
now = Y.Lang.now();
if (now - lastTime > duration) {
lastArgs = null;
lastTime = now;
fn.apply(context, arguments);
} else {
timeout = setTimeout(execute, duration);
}
};
};
});
var result;
</script>
var newThrottled = Y.newThrottle(function (n) { result = Math.random() + n; }, 200),
oldThrottled = Y.throttle(function (n) { result = Math.random() + n; }, 200);
console.log(result);
Ready to run.
Test | Ops/sec | |
---|---|---|
New Y.throttle() |
| ready |
Old Y.throttle() |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.