Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1318 Rev 1422
1
/*
1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
3
	All Rights Reserved.
4
 
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
9
*/
-
 
10
 
-
 
11
 
10
 
12
 
11
dojo.provide("dojo.profile");
13
dojo.provide("dojo.profile");
12
dojo.profile = {_profiles:{}, _pns:[], start:function (name) {
14
dojo.profile = {_profiles:{}, _pns:[], start:function (name) {
13
	if (!this._profiles[name]) {
15
	if (!this._profiles[name]) {
14
		this._profiles[name] = {iters:0, total:0};
16
		this._profiles[name] = {iters:0, total:0};
15
		this._pns[this._pns.length] = name;
17
		this._pns[this._pns.length] = name;
16
	} else {
18
	} else {
17
		if (this._profiles[name]["start"]) {
19
		if (this._profiles[name]["start"]) {
18
			this.end(name);
20
			this.end(name);
19
		}
21
		}
20
	}
22
	}
21
	this._profiles[name].end = null;
23
	this._profiles[name].end = null;
22
	this._profiles[name].start = new Date();
24
	this._profiles[name].start = new Date();
23
}, end:function (name) {
25
}, end:function (name) {
24
	var ed = new Date();
26
	var ed = new Date();
25
	if ((this._profiles[name]) && (this._profiles[name]["start"])) {
27
	if ((this._profiles[name]) && (this._profiles[name]["start"])) {
26
		with (this._profiles[name]) {
28
		with (this._profiles[name]) {
27
			end = ed;
29
			end = ed;
28
			total += (end - start);
30
			total += (end - start);
29
			start = null;
31
			start = null;
30
			iters++;
32
			iters++;
31
		}
33
		}
32
	} else {
34
	} else {
33
		return true;
35
		return true;
34
	}
36
	}
35
}, dump:function (appendToDoc) {
37
}, dump:function (appendToDoc) {
36
	var tbl = document.createElement("table");
38
	var tbl = document.createElement("table");
37
	with (tbl.style) {
39
	with (tbl.style) {
38
		border = "1px solid black";
40
		border = "1px solid black";
39
		borderCollapse = "collapse";
41
		borderCollapse = "collapse";
40
	}
42
	}
41
	var hdr = tbl.createTHead();
43
	var hdr = tbl.createTHead();
42
	var hdrtr = hdr.insertRow(0);
44
	var hdrtr = hdr.insertRow(0);
43
	var cols = ["Identifier", "Calls", "Total", "Avg"];
45
	var cols = ["Identifier", "Calls", "Total", "Avg"];
44
	for (var x = 0; x < cols.length; x++) {
46
	for (var x = 0; x < cols.length; x++) {
45
		var ntd = hdrtr.insertCell(x);
47
		var ntd = hdrtr.insertCell(x);
46
		with (ntd.style) {
48
		with (ntd.style) {
47
			backgroundColor = "#225d94";
49
			backgroundColor = "#225d94";
48
			color = "white";
50
			color = "white";
49
			borderBottom = "1px solid black";
51
			borderBottom = "1px solid black";
50
			borderRight = "1px solid black";
52
			borderRight = "1px solid black";
51
			fontFamily = "tahoma";
53
			fontFamily = "tahoma";
52
			fontWeight = "bolder";
54
			fontWeight = "bolder";
53
			paddingLeft = paddingRight = "5px";
55
			paddingLeft = paddingRight = "5px";
54
		}
56
		}
55
		ntd.appendChild(document.createTextNode(cols[x]));
57
		ntd.appendChild(document.createTextNode(cols[x]));
56
	}
58
	}
57
	for (var x = 0; x < this._pns.length; x++) {
59
	for (var x = 0; x < this._pns.length; x++) {
58
		var prf = this._profiles[this._pns[x]];
60
		var prf = this._profiles[this._pns[x]];
59
		this.end(this._pns[x]);
61
		this.end(this._pns[x]);
60
		if (prf.iters > 0) {
62
		if (prf.iters > 0) {
61
			var bdytr = tbl.insertRow(true);
63
			var bdytr = tbl.insertRow(true);
62
			var vals = [this._pns[x], prf.iters, prf.total, parseInt(prf.total / prf.iters)];
64
			var vals = [this._pns[x], prf.iters, prf.total, parseInt(prf.total / prf.iters)];
63
			for (var y = 0; y < vals.length; y++) {
65
			for (var y = 0; y < vals.length; y++) {
64
				var cc = bdytr.insertCell(y);
66
				var cc = bdytr.insertCell(y);
65
				cc.appendChild(document.createTextNode(vals[y]));
67
				cc.appendChild(document.createTextNode(vals[y]));
66
				with (cc.style) {
68
				with (cc.style) {
67
					borderBottom = "1px solid gray";
69
					borderBottom = "1px solid gray";
68
					paddingLeft = paddingRight = "5px";
70
					paddingLeft = paddingRight = "5px";
69
					if (x % 2) {
71
					if (x % 2) {
70
						backgroundColor = "#e1f1ff";
72
						backgroundColor = "#e1f1ff";
71
					}
73
					}
72
					if (y > 0) {
74
					if (y > 0) {
73
						textAlign = "right";
75
						textAlign = "right";
74
						borderRight = "1px solid gray";
76
						borderRight = "1px solid gray";
75
					} else {
77
					} else {
76
						borderRight = "1px solid black";
78
						borderRight = "1px solid black";
77
					}
79
					}
78
				}
80
				}
79
			}
81
			}
80
		}
82
		}
81
	}
83
	}
82
	if (appendToDoc) {
84
	if (appendToDoc) {
83
		var ne = document.createElement("div");
85
		var ne = document.createElement("div");
84
		ne.id = "profileOutputTable";
86
		ne.id = "profileOutputTable";
85
		with (ne.style) {
87
		with (ne.style) {
86
			fontFamily = "Courier New, monospace";
88
			fontFamily = "Courier New, monospace";
87
			fontSize = "12px";
89
			fontSize = "12px";
88
			lineHeight = "16px";
90
			lineHeight = "16px";
89
			borderTop = "1px solid black";
91
			borderTop = "1px solid black";
90
			padding = "10px";
92
			padding = "10px";
91
		}
93
		}
92
		if (document.getElementById("profileOutputTable")) {
94
		if (document.getElementById("profileOutputTable")) {
93
			dojo.body().replaceChild(ne, document.getElementById("profileOutputTable"));
95
			dojo.body().replaceChild(ne, document.getElementById("profileOutputTable"));
94
		} else {
96
		} else {
95
			dojo.body().appendChild(ne);
97
			dojo.body().appendChild(ne);
96
		}
98
		}
97
		ne.appendChild(tbl);
99
		ne.appendChild(tbl);
98
	}
100
	}
99
	return tbl;
101
	return tbl;
100
}};
102
}};
101
dojo.profile.stop = dojo.profile.end;
103
dojo.profile.stop = dojo.profile.end;
102
 
104