Function Call Overhead (v2)

Revision 2 of this benchmark created on


Description

Testing the overhead of function calls that might otherwise be able to be inlined with some form of optimization like the Google Closure compiler.

Setup

var lazy = function(e) {
        return function() {
            if (typeof e == 'string') {
                return '(' + e + ')';
            } else {
                return '(' + e() + ')';
            }
        }
    };
    
    var eager = function (e) {
        return '(' + e + ')';
    }
    
    var inlined = function(e) {
        return  ('(' + ('(' + ('(' + ('(' + ('(' + e + ')') + ')') + ')') + ')') + ')');
    }
    
    var joined = function(e) {
        return ['(', '(', '(', '(', '(', e, ')', ')', ')', ')', ')'].join('');
    }
    
    var simple = function(e) {
        return '(((((' + e + ')))))'
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Lazy
lazy(lazy(lazy(lazy(lazy('test')))))()
ready
Eager
eager(eager(eager(eager(eager('test')))))
ready
Inline
inlined('test')
ready
Simple
simple('test')
ready
Joined
joined('test')
ready

Revisions

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