forked from KoryNunn/crel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
72 lines (61 loc) · 2.07 KB
/
test.html
File metadata and controls
72 lines (61 loc) · 2.07 KB
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
<!DOCTYPE html>
<html>
<head>
<style>
div{
border:1px solid red;
}
span{
border:1px solid green;
}
a{
border:1px solid blue;
}
.someClass{
border:1px solid purple;
}
</style>
<script src="crel.js"></script>
<script src="https://rawgithub.com/KoryNunn/bench/master/bench.js"></script>
<script>
window.onload = function(){
document.getElementsByTagName('body')[0].appendChild(crel('div', crel('div', {'class':'someClass'}, crel('a',{href:'http://www.google.com/'}, 'Link to google')), crel('span')));
var bench = new Bench();
// Test normal
bench.addTest(function(){
var result = document.createElement('div');
result.setAttribute('stuff','things');
result.appendChild(document.createElement('a'));
}, "document.CreateElement");
// Test crel
bench.addTest(function(){
crel('div',{stuff:'things'},crel('a'));
}, "crel");
createElement = function(type){
return document.createElement(type);
}
// Test createElement with 1 layer of proxy.
bench.addTest(function(){
var result = createElement('div');
result.setAttribute('stuff','things');
result.appendChild(createElement('a'));
}, "proxy");
// Test normal for empty nodes.
bench.addTest(function(){
document.createElement('div');
}, "document.createElement empty node");
// Test crel for empty nodes.
bench.addTest(function(){
crel('div');
}, "crel empty node");
bench.run();
for(var i = 0; i < bench.tests.length; i++){
var test = bench.tests[i]
document.getElementsByTagName('body')[0].appendChild(crel('p',test.name + " runtime: " + test.result + "ms"));
}
};
</script>
</head>
<body>
</body>
</html>