818
Du
dustymarkdown / files
dustymarkdown / node_modules / dust / benchmark / index.html
4.8 KB
1<!DOCTYPE HTML> 2<html> 3 <head> 4 <title>shootout</title> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 6 <style type="text/css"> 7 body { 8 background-color: #eee; 9 font-family: Helvetica, Arial, sans-serif; 10 margin: 0 10%; 11 text-shadow: white 1px 1px 0px; 12 } 13 14 p { 15 color: #777; 16 } 17 18 #header p { 19 color: #555; 20 font-size: 1.1em; 21 font-weight: bold; 22 } 23 24 h1 { 25 font-size: 7em; 26 font-weight: bold; 27 color: #333; 28 margin-top: 0.10em; 29 margin-bottom: -0.25em; 30 } 31 32 .chart { 33 border: 4px solid #ccc; 34 float: left; 35 margin-right: 1em; 36 margin-bottom: 1em; 37 } 38 39 #control { 40 margin-bottom: 1em; 41 } 42 43 #progress { 44 -moz-border-radius: 4px; 45 -webkit-border-radius: 4px; 46 border: 1px solid #aaa; 47 padding: 2px; 48 } 49 50 #progress div { 51 -moz-border-radius: 4px; 52 -webkit-border-radius: 4px; 53 height: 25px; 54 width: 0%; 55 background-color: #888; 56 } 57 </style> 58 </head> 59 <body> 60 <div id="header"> 61 <h1>shootout</h1> 62 <p>Template benchmarks (ops per millisecond)</p> 63 </div> 64 65 <div id="control"> 66 <div id="progress"><div></div></div> 67 <button id="run" style="display:none;">Run</button> 68 </div> 69 70 <div id="content"> 71 <div id="charts"></div> 72 <p style="clear: both">Targets: <a href="http://akdubya.github.com/dustjs">Dust</a>, <a href="http://github.com/wycats/handlebars.js">Handlebars</a>, <a href="http://mustache.github.com/">Mustache</a>, <a href="http://api.jquery.com/tmpl/">jquery-tmpl</a>. Each benchmark runs once using an adaptive test cycles algorithm similar to the one found in <a href="http://github.com/broofa/jslitmus">jslitmus</a>.</p> 73 </div> 74 75 <script src="../vendor/jquery.min.js"></script> 76 <script src="uubench.js"></script> 77 <script src="../dist/dust-full-0.2.5.min.js"></script> 78 <script src="suites/dust_suite.js"></script> 79 <script src="suites/mustache_suite.js"></script> 80 <script src="suites/handlebars_suite.js"></script> 81 <script src="suites/jquery_suite.js"></script> 82 <script src="http://github.com/wycats/handlebars.js/raw/766497bb553a926c046c5e5b50ee35529d168ba5/lib/handlebars.js"></script> 83 <script src="http://github.com/janl/mustache.js/raw/master/mustache.js"></script> 84 <script src="http://github.com/jquery/jquery-tmpl/raw/master/jquery.tmpl.js"></script> 85 <script type="text/javascript" src="http://www.google.com/jsapi"></script> 86 <script type="text/javascript"> 87 google.load('visualization', '1.0', {packages: ['imagechart']}); 88 </script> 89 90 <script> 91 $(document).ready(function(){ 92 var testQueue = []; 93 var $bar = $('#progress > div'); 94 var tick; 95 96 function runAll() { 97 $bar.css('width', "0%"); 98 $('#progress').show(); 99 for (var key in dustBench.benches) { testQueue.push(key) } 100 tick = 100 / testQueue.length; 101 $('#charts').empty(); 102 next(); 103 } 104 105 function next() { 106 var test = testQueue.shift(); 107 if (test) { 108 runSuite(test); 109 } else { 110 $('#progress').fadeOut(1000, function() { 111 $('#run').fadeIn(); 112 }); 113 } 114 } 115 116 function runSuite(type) { 117 var rows = []; 118 var suite = new uubench.Suite({ 119 iterations: 1000, 120 result: function(name, stats) { 121 var opms = stats.iterations/stats.elapsed; 122 rows.push([name, opms]); 123 }, 124 start: function() { 125 $('#charts').append("<div id=\"" + type + "\" class=\"chart\"></div>"); 126 }, 127 done: function() { 128 var pct = parseFloat($bar.css('width')) + tick; 129 drawBarChart(type, rows); 130 $('#progress > div').css('width', pct + "%"); 131 next(); 132 } 133 }); 134 dustBench(suite, type, "dust"); 135 handlebarsBench(suite, type, "handlebars"); 136 mustacheBench(suite, type, "mustache"); 137 jqueryBench(suite, type, "jquery"); 138 suite.run(); 139 } 140 141 function drawBarChart(type, rows) { 142 var dataTable = new google.visualization.DataTable(); 143 dataTable.addColumn("string", "engine"); 144 dataTable.addColumn("number", "ops"); 145 dataTable.addRows(rows); 146 147 var chart = new google.visualization.ImageChart(document.getElementById(type)); 148 chart.draw(dataTable, {title: type, cht: 'bhs', chs: '420x175'}); 149 } 150 151 $('#run').click(function() { 152 $('#run').hide(); 153 runAll(); 154 return false; 155 }); 156 157 runAll(); 158 }); 159 </script> 160 </body> 161</html>