seajs-vs-requirejs

JavaScript performance comparison

Test case created by lifesinger

Preparation code

<script src="https://raw.github.com/jrburke/almond/latest/almond.js"></script>
<script>
var almond = requirejs;
almond.define = define;
almond.require = require;
window.define = undefined;
window.require = undefined;
window.requirejs = undefined;
</script>

<script src="http://requirejs.org/docs/release/2.1.4/minified/require.js"></script>
<script> 
requirejs.define = define;
window.define = undefined;
</script>

<script src="http://seajs.org/dist/sea.js"></script>
<script>
seajs.define = define;
</script>

 
<script>
Benchmark.prototype.setup = function() {
    requirejs.define("module-0", [ ], function () {return { value: '0' };});
    requirejs.define("module-1", [ "module-0" ], function (mod) {return { value: mod.value };});
    requirejs.define("module-2", [ "module-1" ], function (mod) {return { value: mod.value };});
    requirejs.define("module-3", [ "module-2" ], function (mod) {return { value: mod.value };});
    requirejs.define("module-4", [ "module-3" ], function (mod) {return { value: mod.value };});
    requirejs.define("module-5", [ "module-4" ], function (mod) {return { value: mod.value };});
    requirejs.define("module-6", [ "module-5" ], function (mod) {return { value: mod.value };});
    requirejs.define("module-7", [ "module-6" ], function (mod) {return { value: mod.value };});
    requirejs.define("module-8", [ "module-7" ], function (mod) {return { value: mod.value };});
    requirejs.define("module-9", [ "module-8" ], function (mod) {return { value: mod.value };});
    requirejs.define("module-10", [ "module-9" ], function (mod) {return { value: mod.value };});
   
    almond.define("module-0", [ ], function () {return { value: '0' };});
    almond.define("module-1", [ "module-0" ], function (mod) {return { value: mod.value };});
    almond.define("module-2", [ "module-1" ], function (mod) {return { value: mod.value };});
    almond.define("module-3", [ "module-2" ], function (mod) {return { value: mod.value };});
    almond.define("module-4", [ "module-3" ], function (mod) {return { value: mod.value };});
    almond.define("module-5", [ "module-4" ], function (mod) {return { value: mod.value };});
    almond.define("module-6", [ "module-5" ], function (mod) {return { value: mod.value };});
    almond.define("module-7", [ "module-6" ], function (mod) {return { value: mod.value };});
    almond.define("module-8", [ "module-7" ], function (mod) {return { value: mod.value };});
    almond.define("module-9", [ "module-8" ], function (mod) {return { value: mod.value };});
    almond.define("module-10", [ "module-9" ], function (mod) {return { value: mod.value };});
   
    seajs.define("module-0", [ ], function (require, exports, module) {module.exports = { value: '0' };});
    seajs.define("module-1", [ "module-0" ], function (require, exports, module) {module.exports = require("module-0");});
    seajs.define("module-2", [ "module-1" ], function (require, exports, module) {module.exports = require("module-1");});
    seajs.define("module-3", [ "module-2" ], function (require, exports, module) {module.exports = require("module-2");});
    seajs.define("module-4", [ "module-3" ], function (require, exports, module) {module.exports = require("module-3");});
    seajs.define("module-5", [ "module-4" ], function (require, exports, module) {module.exports = require("module-4");});
    seajs.define("module-6", [ "module-5" ], function (require, exports, module) {module.exports = require("module-5");});
    seajs.define("module-7", [ "module-6" ], function (require, exports, module) {module.exports = require("module-6");});
    seajs.define("module-8", [ "module-7" ], function (require, exports, module) {module.exports = require("module-7");});
    seajs.define("module-9", [ "module-8" ], function (require, exports, module) {module.exports = require("module-8");});
    seajs.define("module-10", [ "module-9" ], function (require, exports, module) {module.exports = require("module-9");});
   
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
seajs
// async test
seajs.use('module-10', function (mod) {
  if (mod.value !== '0') throw 'WRONG';
  deferred.resolve();
});
pending…
requirejs
// async test
require(['module-10'], function (mod) {
  if (mod.value !== '0') throw 'WRONG';
  deferred.resolve();
});
pending…
almond
// async test
almond.require(['module-10'], function (mod) {
  if (mod.value !== '0') throw 'WRONG';
  deferred.resolve();
});
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment