Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Update to use the latest Swig version (1.0.0-rc3) #14

@lexagosto

Description

@lexagosto

Hello,
I've just patched the bench suite to upgrade both Swig (to 1.0.0-rc3) and EJS (to 0.8.4).

This is what I actually did, because I was interested in evaluating those templates by performances.

diff --git a/lib/languages/swig.js b/lib/languages/swig.js
index 37b1318..cd97e56 100644
--- a/lib/languages/swig.js
+++ b/lib/languages/swig.js
@@ -13,16 +13,13 @@ var swig = require('swig'),
     },
     tpl = {};

-swig.init({
-    root: __dirname + '/../templates/swig'
-});

 exports.compile = function (type, callback) {
-    tpl[type] = swig.fromString(files[type]);
+    tpl[type] = swig.compile(files[type]);
     callback();
 };

 exports.render = function (type, callback) {
-    tpl[type].render(data);
+    tpl[type](data);
     callback();
 };

While I left the ejs example as-is since it was running properly.

Other tests was not modified, by the way I was surprised by results:

swig complete
Raw:
 > 3.4625374625374628
 > 3.195804195804196
 > 3.4115884115884114
 > 3.3766233766233764
 > 3.4015984015984015
 > 3.5944055944055946
 > 3.2987012987012987
 > 3.4645354645354645
Average (mean) 3.4007242757242757

ejs complete
Raw:
 > 12.32967032967033
 > 12.218781218781219
 > 12.713286713286713
 > 12.401598401598402
 > 12.577422577422578
 > 12.305694305694306
 > 12.722277722277722
 > 12.607392607392608
Average (mean) 12.484515484515486

Why is swig so slow? Am I doing something wrong? Or it's just because of the release-candidate status? (I did not test with other versions). EJS performs 4x better actually.

Note: I did not modify templates so maybe something there is outdated justifying these results.

P.S. once I complete my tests I'll make a pull request.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions