Formatter Performance

JavaScript performance comparison

Test case created

Info

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="https://raw.github.com/DamonOehlman/formatter/master/pkg/oldschool/formatter.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0.beta2/handlebars.min.js"></script>
<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 }}.');
};
</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
Formatter Numeric Args
var test = likefood('bacon', 'bread');
pending…
Formatter Named Args
var test = likefood({ great: 'bacon', poor: 'bread' });
pending…
Handlebars Equivalent
var test = likefoodHBS({ great: 'bacon', poor: 'bread' });
pending…

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

Compare results of other browsers

0 comments

Add a comment