Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update benchmark suite for node 0.8

  • Loading branch information...
commit f5079765ff2ffaa33f82281b8eddd908781ae7d7 1 parent 24fc3a2
@kpdecker kpdecker authored
View
14 Rakefile
@@ -92,20 +92,6 @@ directory "vendor"
desc "benchmark against dust.js and mustache.js"
task :bench => "vendor" do
require "open-uri"
- #File.open("vendor/mustache.js", "w") do |file|
- #file.puts open("https://github.com/janl/mustache.js/raw/master/mustache.js").read
- #file.puts "module.exports = Mustache;"
- #end
-
- File.open("vendor/benchmark.js", "w") do |file|
- file.puts open("https://raw.github.com/bestiejs/benchmark.js/master/benchmark.js").read
- end
-
- #if File.directory?("vendor/dustjs")
- #system "cd vendor/dustjs && git pull"
- #else
- #system "git clone git://github.com/akdubya/dustjs.git vendor/dustjs"
- #end
#if File.directory?("vendor/coffee")
#system "cd vendor/coffee && git pull"
View
2  bench/benchwarmer.js
@@ -133,7 +133,7 @@ BenchWarmer.prototype = {
if(!bench.error) {
var count = bench.hz,
- moe = count * bench.stats.RME / 100;
+ moe = count * bench.stats.rme / 100;
out = Math.round(count / 1000) + " ±" + Math.round(moe / 1000) + " (" + bench.cycles + ")";
} else {
View
77 bench/handlebars.js
@@ -1,20 +1,22 @@
-require.paths.push("lib");
-require.paths.push("vendor");
-require.paths.push("vendor/dustjs/lib");
-require.paths.push("vendor/coffee/lib");
-require.paths.push("vendor/eco/lib");
+var BenchWarmer = require("./benchwarmer");
+Handlebars = require("../lib/handlebars");
+var dust, Mustache, eco;
-var BenchWarmer = require("./benchwarmer");
-Handlebars = require("handlebars");
+try {
+ dust = require("dust");
+} catch (err) { /* NOP */ }
-var dust = require("dust");
-var Mustache = require("mustache");
-var ecoExports = require("eco");
+try {
+ Mustache = require("mustache");
+} catch (err) { /* NOP */ }
-eco = function(str) {
- return ecoExports(str);
-}
+try {
+ var ecoExports = require("eco");
+ eco = function(str) {
+ return ecoExports(str);
+ }
+} catch (err) { /* NOP */ }
var benchDetails = {
string: {
@@ -113,39 +115,46 @@ var makeSuite = function(name) {
var error = function() { throw new Error("EWOT"); };
-
- //bench("dust", function() {
- //dust.render(templateName, context, function(err, out) { });
- //});
+ if (dust) {
+ bench("dust", function() {
+ dust.render(templateName, context, function(err, out) { });
+ });
+ }
bench("handlebars", function() {
handlebarsTemplates[templateName](context);
});
- //if(ecoTemplates[templateName]) {
- //bench("eco", function() {
- //ecoTemplates[templateName](context);
- //});
- //} else {
- //bench("eco", error);
- //}
-
- //if(mustacheSource) {
- //bench("mustache", function() {
- //Mustache.to_html(mustacheSource, context, mustachePartials);
- //});
- //} else {
- //bench("mustache", error);
- //}
+ if (eco) {
+ if(ecoTemplates[templateName]) {
+ bench("eco", function() {
+ ecoTemplates[templateName](context);
+ });
+ } else {
+ bench("eco", error);
+ }
+ }
+
+ if (Mustache && mustacheSource) {
+ bench("mustache", function() {
+ Mustache.to_html(mustacheSource, context, mustachePartials);
+ });
+ } else {
+ bench("mustache", error);
+ }
});
}
for(var name in benchDetails) {
if(benchDetails.hasOwnProperty(name)) {
- dust.loadSource(dust.compile(benchDetails[name].dust, name));
+ if (dust) {
+ dust.loadSource(dust.compile(benchDetails[name].dust, name));
+ }
handlebarsTemplates[name] = Handlebars.compile(benchDetails[name].handlebars);
- if(benchDetails[name].eco) { ecoTemplates[name] = eco(benchDetails[name].eco); }
+ if (eco && benchDetails[name].eco) {
+ ecoTemplates[name] = eco(benchDetails[name].eco);
+ }
var partials = benchDetails[name].partials;
if(partials) {
View
5 package.json
@@ -18,8 +18,11 @@
"uglify-js": "~1.2"
},
"devDependencies": {
+ "benchmark": "~1.0",
+ "dust": "~0.3",
"jison": "~0.3",
- "mocha": "*"
+ "mocha": "*",
+ "mustache": "~0.7.2"
},
"main": "lib/handlebars.js",
"bin": {
Please sign in to comment.
Something went wrong with that request. Please try again.