Permalink
Browse files

Add benchmark

  • Loading branch information...
1 parent 4a0f1c1 commit 164c418eab7b5acd1960671b8160c888055bfab3 @akaspin committed Jul 21, 2010
Showing with 65 additions and 10 deletions.
  1. +9 −3 Makefile
  2. +20 −7 readme.md
  3. +36 −0 test/benchmark-million-complex.js
View
@@ -8,8 +8,14 @@ PASS=echo PASS
test:
@for i in test/test-*.js; do \
- echo -n "$$i: "; \
- $(NODE) $$i > /dev/null && $(PASS) || $(FAIL); \
+ echo -n "$$i: "; \
+ $(NODE) $$i > /dev/null && $(PASS) || $(FAIL); \
done
-.PHONY: test
+benchmark:
+ @for i in test/benchmark-*.js; do \
+ echo -n "$$i: "; \
+ $(NODE) $$i; \
+ done
+
+.PHONY: test benchmark
View
@@ -77,7 +77,11 @@ Instead of rendering the template can be compiled for future use.
To run the tests:
cd where/is/nun
- make
+ make
+
+... And for run bencmark:
+
+ make benchmark
## Basic syntax
@@ -577,19 +581,28 @@ compile-phase filters, you can compress all whitespace in template by setting
nun.render(__dirname + "/file.html", {}, { compress: true }, ...);
-## Why Nun...
+## How Nun...
+
+### ... use paths?
+
+Nun uses absolute paths for independence. For example, if you write your
+library using *nun*, a single global way will only interfere.
-### ... uses absolute paths?
+### ... is fast?
-For independence. For example, if you write your library using *nun*, a single
-global way will only interfere.
+So since version 0.1.101 *nun* totally refactored. On my test VM slightly
+tuned "million-comlex" benchmark from mustache taken *about 45 seconds*.
-### ... is Nun?
+You can run benchmark as follows:
+
+ cd where/is/nun
+ make benchmark
+
+### ... become Nun?
Nun architecture a bit similar to Mu. "Nun" is the letter of the Phoenician
alphabet that means snake or fish, corresponding to the Greek "Nu", which
follows the "Mu".
-
@@ -0,0 +1,36 @@
+var path = require("path");
+var nun = require("../");
+
+var name = "complex";
+
+var fixture = require("./fixtures/" + name);
+var file = path.normalize(__dirname + "/fixtures/" + name + ".html");
+
+console.log("Million complex benchmark");
+console.log(file);
+
+nun.compile(file, fixture.options, function(err, compiled) {
+ if (err) {
+ throw err;
+ }
+
+ var buffer = "";
+ compiled(fixture.context)
+ .on('data', function (c) { buffer += c; })
+ .on('end', function () { console.log(buffer); });
+
+ var i = 0;
+ var d = new Date();
+ (function go() {
+ if (i++ < 1000000) {
+ compiled(fixture.context)
+ .on('end', function () {
+ go();
+ });
+ }
+ })();
+
+ process.addListener('exit', function () {
+ console.log("Time taken: " + ((new Date() - d) / 1000) + " secs");
+ });
+});

0 comments on commit 164c418

Please sign in to comment.