My favorites | Sign in
Project Logo
                
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Performance simple example 1</title>
</head>
<body>
<pre>
<script src="../Common.js"></script>
<script src="../tokens.js"></script>
<script src="../code_gen.js"></script>
<script src="../specialize.js"></script>
<script src="../json2.js"></script>

<script>

Function.prototype.specialize = net.higherorder.jeene.Jeene.make();

source_fun = function(tag,clz,cont) {
return "["+tag+" class='"+clz+"']"+cont+"[/"+tag+"]";
};
source = source_fun.toSource? source_fun.toSource() : source_fun.toString();

document.write("Normal:\n\n");
var start,stop,i,res;
start = +new Date;
for (i=0;i<100000;i++) {
source_fun("div","green",String(i));
if (i === 500)
res = source_fun("div","green",String(i));
}
stop = +new Date;

document.write(res+": "+(stop-start));
document.write("\n\nPeval.\n\n");
start = +new Date;
var f = source_fun.specialize({tag:'div', clz:'green'});
for (i=0;i<100000;i++) {
f(String(i));
if (i === 500)
res = f(String(i));
}
stop = +new Date;

document.write(res+": "+(stop-start));
document.write("\n\nDone.\n\n");




</script>
</pre>
</body>
</html>
Show details Hide details

Change log

r8 by karl.krukow on Sep 19, 2008   Diff
assignment
Go to: 
Project members, sign in to write a code review

Older revisions

r5 by karl.krukow on Sep 16, 2008   Diff
removed optimizer
r4 by karl.krukow on Sep 15, 2008   Diff
moved reduce to this object
r3 by karl.krukow on Sep 14, 2008   Diff
fixed examples
All revisions of this file

File info

Size: 1423 bytes, 56 lines
Hosted by Google Code