Browse Source

Merge branch 'benchmark' into fat-stride

tags/0.5.0-vsc
Sahab Yazdani 15 years ago
parent
commit
8adad30e52
4 changed files with 2268 additions and 0 deletions
  1. +13
    -0
      test/benchmark.html
  2. +34
    -0
      test/benchmark.js
  3. +2221
    -0
      test/benchmark/benchmark.js
  4. BIN
      test/benchmark/nano.jar

+ 13
- 0
test/benchmark.html View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>mustache.js benchmark tests</title>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script language="JavaScript" type="text/javascript" src="benchmark/benchmark.js"></script>
<script language="JavaScript" type="text/javascript" src="../mustache.js"></script>
<script language="JavaScript" type="text/javascript" src="benchmark.js"></script>
</head>
<body>
<applet code="nano" archive="benchmark/nano.jar"></applet>
</body>
</html>

+ 34
- 0
test/benchmark.js View File

@@ -0,0 +1,34 @@
var tmpl = "This is the story of guys who work on a project\n" +
"called {{project}}. Their names were {{#people}}{{firstName}} and {{/people}}\n" +
"they both enjoyed working on {{project}}.\n\n" +
"{{#people}}\n" +
"{{>personPet}}\n" +
"{{/people}}";
var partials = {
personPet: "{{firstName}} {{lastName}} {{#pet}} owned a {{species}}. Its name was {{name}}.{{/pet}}{{^pet}}didn't own a pet.{{/pet}}"
};
var data = {
project: "Handlebars",
people: [
{ firstName: "Yehuda", lastName: "Katz" },
{ firstName: "Alan", lastName: "Johnson", pet: { species: "cat", name: "Luke" } }
]
}

$(function() {
var bench = new Benchmark('to_html', function() {
Mustache.to_html(tmpl, data, partials);
});
bench.run();
$('<div>' + bench.toString() + '</div>').appendTo(document.body);
var bench = new Benchmark('compiled', function() {
this.compiled_tmpl(data);
}, {
onStart: function() {
this.compiled_tmpl = Mustache.compile(tmpl, partials);
}
});
bench.run();
$('<div>' + bench.toString() + '</div>').appendTo(document.body);
});

+ 2221
- 0
test/benchmark/benchmark.js
File diff suppressed because it is too large
View File


BIN
test/benchmark/nano.jar View File


Loading…
Cancel
Save