Giter Site home page Giter Site logo

templating-benchmarks's Introduction

templating-benchmarks

This project provides a framework for running benchmarks against multiple templating engines under Node.js. The following templating engine modules are currently integrated:

Template Syntax Streaming Asynchronous Auto-escape
dustjs-linkedin Text
doT Text
handlebars Text
pug Short-hand HTML
marko HTML/Concise HTML
nunjucks Text
react1 JSX
swig Text

NOTE 1: While React is not a "templating engine", it is commonly used to render HTML on the server so it has been included in this benchmark.

Table of Contents

Run Benchmarks

  1. Clone this repository
  2. npm install
  3. npm test (or make)

Current Results

The following results were collected with the following setup:

  • Node.js v7.4.0
  • MacBook Pro (Retina, 15-inch, Mid 2014)
  • Processor: 2.8 GHz Intel Core i7
  • Memory: 16 GB 1600 MHz DDR3

Performance

Higher numbers are better.

                      RUNTIME PERFORMANCE
                      ===================
                      friends
                   ✓ marko »    4,780 op/s (fastest)
                    ✗ dust »      868 op/s (81.84% slower)

                      if-expression
                   ✓ marko »  603,718 op/s (fastest)
                     ✗ pug »  495,798 op/s (17.88% slower)
                    ✗ jade »   73,946 op/s (87.75% slower)

                      projects-escaped
                   ✓ marko »  116,897 op/s (fastest)
      ✗ marko (native-for) »  114,487 op/s (2.06% slower)
              ✗ handlebars »   64,465 op/s (44.85% slower)
                    ✗ dust »   41,080 op/s (64.86% slower)

                      projects-unescaped
      ✓ marko (native-for) »  476,404 op/s (fastest)
                   ✗ marko »  416,648 op/s (12.54% slower)
              ✗ handlebars »  182,510 op/s (61.69% slower)
                    ✗ dust »  123,418 op/s (74.09% slower)

                      reverse-helper
                   ✓ marko »  571,518 op/s (fastest)
                    ✗ dust »  361,126 op/s (36.81% slower)

                      search-results
                   ✓ marko »   47,645 op/s (fastest)
                    ✗ dust »   15,447 op/s (67.58% slower)

                      simple-0
                   ✓ marko »  472,020 op/s (fastest)
                     ✗ es6 »  466,638 op/s (1.14% slower)
                  ✗ lodash »  291,743 op/s (38.19% slower)
                    ✗ dust »  250,187 op/s (47.00% slower)

                      simple-1
                     ✓ pug »  415,779 op/s (fastest)
                   ✗ marko »  363,983 op/s (12.46% slower)
                     ✗ dot »  299,093 op/s (28.06% slower)
              ✗ handlebars »  161,886 op/s (61.06% slower)
                    ✗ dust »  135,315 op/s (67.46% slower)
                    ✗ jade »   88,483 op/s (78.72% slower)
                ✗ nunjucks »   56,782 op/s (86.34% slower)
                    ✗ swig »   54,721 op/s (86.84% slower)
                     ✗ vue »   15,601 op/s (96.25% slower)
                   ✗ react »    3,874 op/s (99.07% slower)

                      simple-2
                   ✓ marko »  437,265 op/s (fastest)
                    ✗ dust »  154,719 op/s (64.62% slower)

                      ui-components
                   ✓ marko »  199,304 op/s (fastest)
                   ✗ react »    3,621 op/s (98.18% slower)

Compiled Size

Lower numbers are better.

                      COMPILED SIZE (gzipped/uncompressed)
                      ====================================
                      friends
                    ✓ dust »   489 bytes gzipped    1378 bytes uncompressed
                                      (smallest)                 (smallest)
                   ✗ marko »   667 bytes gzipped    1887 bytes uncompressed
                                   26.69% larger              26.97% larger

                      if-expression
                   ✓ marko »   344 bytes gzipped     680 bytes uncompressed
                                      (smallest)                 (smallest)
                    ✗ jade »   388 bytes gzipped    1049 bytes uncompressed
                                   11.34% larger              35.18% larger
                     ✗ pug »   905 bytes gzipped    2138 bytes uncompressed
                                   61.99% larger              68.19% larger

                      projects-escaped
                    ✓ dust »   262 bytes gzipped     554 bytes uncompressed
                                      (smallest)                 (smallest)
                   ✗ marko »   432 bytes gzipped    1182 bytes uncompressed
                                   39.35% larger              53.13% larger
      ✗ marko (native-for) »   445 bytes gzipped    1182 bytes uncompressed
                                   41.12% larger              53.13% larger
              ✗ handlebars »   558 bytes gzipped    1594 bytes uncompressed
                                   53.05% larger              65.24% larger

                      projects-unescaped
                    ✓ dust »   268 bytes gzipped     586 bytes uncompressed
                                      (smallest)                 (smallest)
                   ✗ marko »   419 bytes gzipped    1125 bytes uncompressed
                                   36.04% larger              47.91% larger
      ✗ marko (native-for) »   433 bytes gzipped    1125 bytes uncompressed
                                   38.11% larger              47.91% larger
              ✗ handlebars »   535 bytes gzipped    1626 bytes uncompressed
                                   49.91% larger              63.96% larger

                      reverse-helper
                    ✓ dust »   147 bytes gzipped     312 bytes uncompressed
                                      (smallest)                 (smallest)
                   ✗ marko »   246 bytes gzipped     524 bytes uncompressed
                                   40.24% larger              40.46% larger

                      search-results
                    ✓ dust »   544 bytes gzipped    1514 bytes uncompressed
                                      (smallest)               0.59% larger
                   ✗ marko »   597 bytes gzipped    1505 bytes uncompressed
                                    8.88% larger                 (smallest)

                      simple-0
                    ✓ dust »   173 bytes gzipped     234 bytes uncompressed
                                      (smallest)                 (smallest)
                   ✗ marko »   213 bytes gzipped     345 bytes uncompressed
                                   18.78% larger              32.17% larger

                      simple-1
                   ✓ react »   395 bytes gzipped     850 bytes uncompressed
                                      (smallest)               5.53% larger
                    ✗ dust »   413 bytes gzipped     884 bytes uncompressed
                                    4.36% larger               9.16% larger
                   ✗ marko »   485 bytes gzipped     956 bytes uncompressed
                                   18.56% larger              16.00% larger
                     ✗ dot »   491 bytes gzipped     803 bytes uncompressed
                                   19.55% larger                 (smallest)
                    ✗ jade »   524 bytes gzipped    1116 bytes uncompressed
                                   24.62% larger              28.05% larger
                ✗ nunjucks »   599 bytes gzipped    1367 bytes uncompressed
                                   34.06% larger              41.26% larger
              ✗ handlebars »   617 bytes gzipped    1492 bytes uncompressed
                                   35.98% larger              46.18% larger
                    ✗ swig »   756 bytes gzipped    3378 bytes uncompressed
                                   47.75% larger              76.23% larger
                     ✗ pug »  1047 bytes gzipped    2304 bytes uncompressed
                                   62.27% larger              65.15% larger

                      simple-2
                    ✓ dust »   267 bytes gzipped     639 bytes uncompressed
                                      (smallest)                 (smallest)
                   ✗ marko »   311 bytes gzipped     739 bytes uncompressed
                                   14.15% larger              13.53% larger

                      ui-components
                   ✓ react »   204 bytes gzipped     310 bytes uncompressed
                                      (smallest)                 (smallest)
                   ✗ marko »   274 bytes gzipped     559 bytes uncompressed
                                   25.55% larger              44.54% larger

Client-side Runtime Sizes

Below are the approximate runtime sizes for each engine (lower numbers are better):

Marko

| Modules | Size | | ------------- |:-------------:| -----:| | marko | ~1.2KB gzipped (2.7KB uncompressed) | | marko +
async-writer +
raptor-xml/util | ~2.33KB gzipped (6.3KB uncompressed) |

NOTE: Sizes are approximate because overhead associated with the CommonJS module loader varies. Size based on code as of April 7, 2014.

Dust

| Modules | Size | | ------------- |:-------------:| -----:| | dust-core | 3.41KB gzipped (10.07KB uncompressed) | | dust-core +
dust-helpers | 4.7KB gzipped (14.2KB uncompressed) |

NOTE: Size based on code as of April 7, 2014.

Contribute

Adding a New Comparison Group

Each comparison group should contain a data file (either data.json or data.js) and a set of templates to compare. The file extension of the template will be used to determine which engine should be used. If the data file has the .js extension then it should be a JavaScript module that exports the data. A sample directory structure is shown below:

templates
    ├── group1
    │   ├── data.js
    │   ├── template.dust
    │   └── template.marko
    ├── group2
    │   ├── data.json
    │   ├── template.dust
    │   └── template.marko
    ├── group3
    │   ├── data.json
    │   ├── template.dust
    │   ├── template.native-for.marko
    │   └── template.marko
    └── group4
        ├── data.json
        ├── template.dust
        └── template.marko

Adding a New Template Engine

To register a new templating engine, simply create a new module under the engines directory and it will automatically be loaded. See existing engine modules for supported methods and properties.

Pull Requests welcome!

templating-benchmarks's People

Contributors

austinkelleher avatar denizdogan avatar greenkeeper[bot] avatar indexzero avatar jmatc avatar mlrawlings avatar patrick-steele-idem avatar seangates avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

templating-benchmarks's Issues

An in-range update of marko is breaking the build 🚨

Version 4.10.0 of marko was just published.

Branch Build failing 🚨
Dependency marko
Current Version 4.9.7
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

marko is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 11 commits.

  • d6e251d 4.10.0
  • 6e55f14 Fix #1049 - Fix documentation urls on the website.
  • 5d3e976 Merge pull request #1046 from marko-js/add-failing-tests-from-branches
  • 048a563 Add failing test cases from branches.
  • 7c5089b Merge pull request #1041 from marko-js/on-mount-update-test
  • 1a37333 Add same test for legacy compatibility layer.
  • 5be4d52 Add test for updating in onMount
  • 28ff4e1 fix markdown formatting
  • 6489961 Delete ISSUE_TEMPLATE.md
  • 2433543 Update issue templates
  • 89dfb4b Fixes #877 - Allow array of transformers in marko.json. (#1034)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of nunjucks is breaking the build 🚨

Version 3.1.3 of nunjucks was just published.

Branch Build failing 🚨
Dependency nunjucks
Current Version 3.1.2
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

nunjucks is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v3.1.3
  • Add forceescape filter. Fixes #782

  • Fix regression that prevented template errors from reporting line and column number. Fixes #1087 and #1095.

  • Fix "Invalid type: Is" error for {% if value is defined %}. Fixes #1110

  • Formally drop support for node v4 (the upgrade to babel 7 in v3.1.0 made the build process incompatible with node < 6.9.0).

Commits

The new version differs by 15 commits.

  • 9a0ce36 3.13 release - fix typo in CHANGELOG
  • c2de0e4 Release 3.1.3
  • 4d8a4cc Update chokidar optionalDependency. Fixes #1103
  • d140280 Update CONTRIBUTING.md to reflect supported node releases [ci skip]
  • af6427d Update CHANGELOG
  • 1b76fb8 Update package.json engines to reflect supported node versions
  • 8afacce Add unit tests for {% if x is [not] defined %}. refs #1110
  • 248cf56 Fix "Invalid type: Is" error when using {% if x is defined %}
  • 2eaea16 Drop node v4 support, add node v9
  • 8041120 Include file/lineno in TemplateError message. fixes #1087, #1095
  • 1b4558d Merge pull request #1090 from TheDancingCode/forceescape
  • f478b06 Add "forceescape" filter
  • de49d33 Merge pull request #1089 from gingerrific/master
  • 3ab849c Update remaining src links
  • dedb978 Update API.md links to use correct paths

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Nunjucks can configure auto escape

Hi guys!

With Nunjucks you can set the auto-escape:

nunjucks.configure('views', {
  autoescape: true
  express   : app
});

Regards, Nicholls

An in-range update of uglify-js is breaking the build 🚨

Version 3.3.25 of uglify-js was just published.

Branch Build failing 🚨
Dependency uglify-js
Current Version 3.3.24
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

uglify-js is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v3.3.25

 

Commits

The new version differs by 5 commits.

  • f72d302 v3.3.25
  • 1a0d6ed remove colors dependency (#3133)
  • 7b59b2f replace mocha dependency (#3131)
  • 7bc7704 fix corner case in reduce_vars (#3129)
  • 14e712e fix corner case in call binding (#3128)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

convert handlebars templates to markojs

Is there an easy way to compile/convert handlebar templates (.handlebars) into marko compatible files?

In my project, I have several handlebars files that I precompile into JS and include in my project to be used by calling JS Handlebars.* method. What would be the fastest way to switch to marko for my use case?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.