new vs closure

Benchmark created on


Setup

var O = function () {};
    O.prototype.add = function (a, b) {
        return a + b;
    };
    
    var o = function () {
        var api = function () {};
        api.add = function (a, b) {
            return a + b;
        };
        return api;
    };

Test runner

Ready to run.

Testing in
TestOps/sec
new
(new O).add(1, 2);
ready
closure
o().add(1, 2);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.