Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: test/mjsunit/tools/profile.js

Issue 8888006: Make more JS files beter match the coding standard. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/tools/codemap.js ('k') | test/mjsunit/tools/splaytree.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Load source code files from <project root>/tools. 28 // Load source code files from <project root>/tools.
29 // Files: tools/splaytree.js tools/codemap.js tools/consarray.js tools/profile.j s 29 // Files: tools/splaytree.js tools/codemap.js tools/consarray.js tools/profile.j s
30 30
31 31
32 function stackToString(stack) { 32 function stackToString(stack) {
33 return stack.join(' -> '); 33 return stack.join(' -> ');
34 }; 34 }
35 35
36 36
37 function assertPathExists(root, path, opt_message) { 37 function assertPathExists(root, path, opt_message) {
38 var message = opt_message ? ' (' + opt_message + ')' : ''; 38 var message = opt_message ? ' (' + opt_message + ')' : '';
39 assertNotNull(root.descendToChild(path, function(node, pos) { 39 assertNotNull(root.descendToChild(path, function(node, pos) {
40 assertNotNull(node, 40 assertNotNull(node,
41 stackToString(path.slice(0, pos)) + ' has no child ' + 41 stackToString(path.slice(0, pos)) + ' has no child ' +
42 path[pos] + message); 42 path[pos] + message);
43 }), opt_message); 43 }), opt_message);
44 }; 44 }
45 45
46 46
47 function assertNoPathExists(root, path, opt_message) { 47 function assertNoPathExists(root, path, opt_message) {
48 var message = opt_message ? ' (' + opt_message + ')' : ''; 48 var message = opt_message ? ' (' + opt_message + ')' : '';
49 assertNull(root.descendToChild(path), opt_message); 49 assertNull(root.descendToChild(path), opt_message);
50 }; 50 }
51 51
52 52
53 function countNodes(profile, traverseFunc) { 53 function countNodes(profile, traverseFunc) {
54 var count = 0; 54 var count = 0;
55 traverseFunc.call(profile, function () { count++; }); 55 traverseFunc.call(profile, function () { count++; });
56 return count; 56 return count;
57 }; 57 }
58 58
59 59
60 function ProfileTestDriver() { 60 function ProfileTestDriver() {
61 this.profile = new Profile(); 61 this.profile = new Profile();
62 this.stack_ = []; 62 this.stack_ = [];
63 this.addFunctions_(); 63 this.addFunctions_();
64 }; 64 }
65 65
66 66
67 // Addresses inside functions. 67 // Addresses inside functions.
68 ProfileTestDriver.prototype.funcAddrs_ = { 68 ProfileTestDriver.prototype.funcAddrs_ = {
69 'lib1-f1': 0x11110, 'lib1-f2': 0x11210, 69 'lib1-f1': 0x11110, 'lib1-f2': 0x11210,
70 'lib2-f1': 0x21110, 'lib2-f2': 0x21210, 70 'lib2-f1': 0x21110, 'lib2-f2': 0x21210,
71 'T: F1': 0x50110, 'T: F2': 0x50210, 'T: F3': 0x50410 }; 71 'T: F1': 0x50110, 'T: F2': 0x50210, 'T: F3': 0x50410 };
72 72
73 73
74 ProfileTestDriver.prototype.addFunctions_ = function() { 74 ProfileTestDriver.prototype.addFunctions_ = function() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 this.enter('lib2-f1'); 127 this.enter('lib2-f1');
128 this.enter('lib1-f1'); 128 this.enter('lib1-f1');
129 this.leave(); 129 this.leave();
130 this.leave(); 130 this.leave();
131 this.stay(); 131 this.stay();
132 this.leave(); 132 this.leave();
133 }; 133 };
134 134
135 135
136 function Inherits(childCtor, parentCtor) { 136 function Inherits(childCtor, parentCtor) {
137 function tempCtor() {}; 137 function tempCtor() {}
138 tempCtor.prototype = parentCtor.prototype; 138 tempCtor.prototype = parentCtor.prototype;
139 childCtor.superClass_ = parentCtor.prototype; 139 childCtor.superClass_ = parentCtor.prototype;
140 childCtor.prototype = new tempCtor(); 140 childCtor.prototype = new tempCtor();
141 childCtor.prototype.constructor = childCtor; 141 childCtor.prototype.constructor = childCtor;
142 }; 142 }
143 143
144 144
145 (function testCallTreeBuilding() { 145 (function testCallTreeBuilding() {
146 function Driver() { 146 function Driver() {
147 ProfileTestDriver.call(this); 147 ProfileTestDriver.call(this);
148 this.namesTopDown = []; 148 this.namesTopDown = [];
149 this.namesBottomUp = []; 149 this.namesBottomUp = [];
150 }; 150 }
151 Inherits(Driver, ProfileTestDriver); 151 Inherits(Driver, ProfileTestDriver);
152 152
153 Driver.prototype.enter = function(func) { 153 Driver.prototype.enter = function(func) {
154 this.namesTopDown.push(func); 154 this.namesTopDown.push(func);
155 this.namesBottomUp.unshift(func); 155 this.namesBottomUp.unshift(func);
156 assertNoPathExists(this.profile.getTopDownProfile().getRoot(), this.namesTop Down, 156 assertNoPathExists(this.profile.getTopDownProfile().getRoot(), this.namesTop Down,
157 'pre enter/topDown'); 157 'pre enter/topDown');
158 assertNoPathExists(this.profile.getBottomUpProfile().getRoot(), this.namesBo ttomUp, 158 assertNoPathExists(this.profile.getBottomUpProfile().getRoot(), this.namesBo ttomUp,
159 'pre enter/bottomUp'); 159 'pre enter/bottomUp');
160 Driver.superClass_.enter.call(this, func); 160 Driver.superClass_.enter.call(this, func);
(...skipping 24 matching lines...) Expand all
185 testDriver.execute(); 185 testDriver.execute();
186 })(); 186 })();
187 187
188 188
189 function assertNodeWeights(root, path, selfTicks, totalTicks) { 189 function assertNodeWeights(root, path, selfTicks, totalTicks) {
190 var node = root.descendToChild(path); 190 var node = root.descendToChild(path);
191 var stack = stackToString(path); 191 var stack = stackToString(path);
192 assertNotNull(node, 'node not found: ' + stack); 192 assertNotNull(node, 'node not found: ' + stack);
193 assertEquals(selfTicks, node.selfWeight, 'self of ' + stack); 193 assertEquals(selfTicks, node.selfWeight, 'self of ' + stack);
194 assertEquals(totalTicks, node.totalWeight, 'total of ' + stack); 194 assertEquals(totalTicks, node.totalWeight, 'total of ' + stack);
195 }; 195 }
196 196
197 197
198 (function testTopDownRootProfileTicks() { 198 (function testTopDownRootProfileTicks() {
199 var testDriver = new ProfileTestDriver(); 199 var testDriver = new ProfileTestDriver();
200 testDriver.execute(); 200 testDriver.execute();
201 201
202 var pathWeights = [ 202 var pathWeights = [
203 [['lib1-f1'], 1, 16], 203 [['lib1-f1'], 1, 16],
204 [['lib1-f1', 'lib1-f2'], 2, 15], 204 [['lib1-f1', 'lib1-f2'], 2, 15],
205 [['lib1-f1', 'lib1-f2', 'T: F1'], 2, 11], 205 [['lib1-f1', 'lib1-f2', 'T: F1'], 2, 11],
(...skipping 15 matching lines...) Expand all
221 } 221 }
222 })(); 222 })();
223 223
224 224
225 (function testRootFlatProfileTicks() { 225 (function testRootFlatProfileTicks() {
226 function Driver() { 226 function Driver() {
227 ProfileTestDriver.call(this); 227 ProfileTestDriver.call(this);
228 this.namesTopDown = ['']; 228 this.namesTopDown = [''];
229 this.counters = {}; 229 this.counters = {};
230 this.root = null; 230 this.root = null;
231 }; 231 }
232 Inherits(Driver, ProfileTestDriver); 232 Inherits(Driver, ProfileTestDriver);
233 233
234 Driver.prototype.increment = function(func, self, total) { 234 Driver.prototype.increment = function(func, self, total) {
235 if (!(func in this.counters)) { 235 if (!(func in this.counters)) {
236 this.counters[func] = { self: 0, total: 0 }; 236 this.counters[func] = { self: 0, total: 0 };
237 } 237 }
238 this.counters[func].self += self; 238 this.counters[func].self += self;
239 this.counters[func].total += total; 239 this.counters[func].total += total;
240 }; 240 };
241 241
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 for (var i = 0; i < flatProfile.length; ++i) { 339 for (var i = 0; i < flatProfile.length; ++i) {
340 var rec = flatProfile[i]; 340 var rec = flatProfile[i];
341 assertTrue(rec.label in flatWeights, 'uncounted: ' + rec.label); 341 assertTrue(rec.label in flatWeights, 'uncounted: ' + rec.label);
342 var reference = flatWeights[rec.label]; 342 var reference = flatWeights[rec.label];
343 assertEquals(reference[0], rec.selfWeight, 'self of ' + rec.label); 343 assertEquals(reference[0], rec.selfWeight, 'self of ' + rec.label);
344 assertEquals(reference[1], rec.totalWeight, 'total of ' + rec.label); 344 assertEquals(reference[1], rec.totalWeight, 'total of ' + rec.label);
345 } 345 }
346 346
347 })(); 347 })();
348 348
OLDNEW
« no previous file with comments | « test/mjsunit/tools/codemap.js ('k') | test/mjsunit/tools/splaytree.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698