Formatter Performance

JavaScript performance comparison

Test case created


Checking the performance of the formatter microlib. Performance is checked against Handlebars to ensure I haven't done something silly. Formatter is faster than handlebars, but it's also waaay simpler so that's not surprising.

Preparation code

<script src=""></script>
<script src=""></script>
Benchmark.prototype.setup = function() {
    // define a formatter for liking food
    var likefood = formatter('I like {{ 0 }}, {{ 0 }} is excellent and kicks the pants off {{ 1 }}.'),
        likefoodNamed = formatter('I like {{ great }}, {{ great }} is excellent and kicks the pants off {{ poor }}.'),
        args = ['bacon', 'bread'],
        likefoodHBS = Handlebars.compile('I like {{ great }}, {{ great }} is excellent and kicks the pants off {{ poor }}.');

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
Formatter Numeric Args
var test = likefood('bacon', 'bread');
Formatter Named Args
var test = likefood({ great: 'bacon', poor: 'bread' });
Handlebars Equivalent
var test = likefoodHBS({ great: 'bacon', poor: 'bread' });

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

Compare results of other browsers


Comment form temporarily disabled.

Add a comment