OLD | NEW |
---|---|
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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
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 // Node imports | |
29 if (typeof module !== 'undefined' && module.exports) { | |
30 CodeMap = require('./codemap'); | |
31 ConsArray = require('./consarray'); | |
32 } | |
28 | 33 |
29 /** | 34 /** |
30 * Creates a profile object for processing profiling-related events | 35 * Creates a profile object for processing profiling-related events |
31 * and calculating function execution times. | 36 * and calculating function execution times. |
32 * | 37 * |
33 * @constructor | 38 * @constructor |
34 */ | 39 */ |
35 function Profile() { | 40 function Profile() { |
36 this.codeMap_ = new CodeMap(); | 41 this.codeMap_ = new CodeMap(); |
37 this.topDownTree_ = new CallTree(); | 42 this.topDownTree_ = new CallTree(); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 // root with the node corresponding to the whole program. | 397 // root with the node corresponding to the whole program. |
393 counters.root_ = root; | 398 counters.root_ = root; |
394 } else { | 399 } else { |
395 // Propagate weights so percents can be calculated correctly. | 400 // Propagate weights so percents can be calculated correctly. |
396 counters.getRoot().selfWeight = root.selfWeight; | 401 counters.getRoot().selfWeight = root.selfWeight; |
397 counters.getRoot().totalWeight = root.totalWeight; | 402 counters.getRoot().totalWeight = root.totalWeight; |
398 } | 403 } |
399 return counters; | 404 return counters; |
400 }; | 405 }; |
401 | 406 |
402 | |
Jakob Kummerow
2015/06/19 09:43:53
keep this line
mattloring
2015/06/19 17:29:03
Done.
| |
403 Profile.CEntryNode = function(name, ticks) { | 407 Profile.CEntryNode = function(name, ticks) { |
404 this.name = name; | 408 this.name = name; |
405 this.ticks = ticks; | 409 this.ticks = ticks; |
406 } | 410 } |
407 | 411 |
408 | 412 |
409 Profile.prototype.getCEntryProfile = function() { | 413 Profile.prototype.getCEntryProfile = function() { |
410 var result = [new Profile.CEntryNode("TOTAL", 0)]; | 414 var result = [new Profile.CEntryNode("TOTAL", 0)]; |
411 var total_ticks = 0; | 415 var total_ticks = 0; |
412 for (var f in this.c_entries_) { | 416 for (var f in this.c_entries_) { |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
825 labels, opt_f) { | 829 labels, opt_f) { |
826 for (var pos = 0, curr = this; pos < labels.length && curr != null; pos++) { | 830 for (var pos = 0, curr = this; pos < labels.length && curr != null; pos++) { |
827 var child = curr.findChild(labels[pos]); | 831 var child = curr.findChild(labels[pos]); |
828 if (opt_f) { | 832 if (opt_f) { |
829 opt_f(child, pos); | 833 opt_f(child, pos); |
830 } | 834 } |
831 curr = child; | 835 curr = child; |
832 } | 836 } |
833 return curr; | 837 return curr; |
834 }; | 838 }; |
839 | |
840 // Node exports | |
841 if (typeof module !== 'undefined' && module.exports) { | |
842 module.exports = Profile; | |
843 } | |
OLD | NEW |