/
jqote_benchmark.html
82 lines (74 loc) · 2.61 KB
/
jqote_benchmark.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>JS Template Benchmarks: jQote</title>
<link rel="stylesheet" href="styles.css" type="text/css" media="screen" charset="utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="jquery.benchmark.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.jqote.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="report">
<h1>JS Template Benchmarks: jQote</h1>
<div id="results">
<ul>
<li>Simple Test: <span class="stat" id="simple_test"></span></li>
<li>Loop Test: <span class="stat" id="loop_test"></span></li>
</ul>
</div>
</div>
<div id="output"></div>
<script type="text/x-jqote-template" id="info-tmpl">
<![CDATA[
<div class="test">
<h2>This is a test of <%= this.name %></h2>
<p>The homepage is <a href="<%= this.url %>"><%= this.url %></a>.</p>
<p>The sources is: <%= this.source %></p>
</div>
]]>
</script>
<script type="text/x-jqote-template" id="comment-tmpl">
<div class="comments">
<h3><%= this.header %></h3>
<ul>
<% $.each(this.comments, function(i, comment){ %>
<li class="comment">
<h5><%= comment.name %></h5>
<p><%= comment.body %></p>
</li>
<% }); %>
</ul>
</div>
</script>
<script type="text/javascript">
$(document).ready(function(){
var output = $('#output');
$.benchmarks = {};
$.benchmarks.test_simple = function(){
$('#info-tmpl').jqote({
name: 'jQote',
url: 'http://aefxx.com/jquery-plugins/jqote/',
source: 'http://aefxx.com/files/jquery.jqote.js'
}).appendTo(output);
};
$.benchmarks.loop_test = function(){
var data = {
header: "My Post Comments",
comments: [
{name: "Joe", body: "Thanks for this post!"},
{name: "Sam", body: "Thanks for this post!"},
{name: "Heather", body: "Thanks for this post!"},
{name: "Kathy", body: "Thanks for this post!"},
{name: "George", body: "Thanks for this post!"}
]
};
$('#comment-tmpl').jqote(data).appendTo(output);
};
// use these lines to run the benchmark tests in your browsers JS console
// $.benchmark(1000, '#simple_test', $.benchmarks.test_simple);
// $.benchmark(1000, '#loop_test', $.benchmarks.loop_test);
});
</script>
</body>
</html>