Formatter Performance
JavaScript performance comparison
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.
| Test | Ops/sec | |
|---|---|---|
Formatter Numeric Args |
|
pending… |
Formatter Named Args |
|
pending… |
Handlebars Equivalent |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments