Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 26 matching lines...) Expand all Loading... | |
| 37 this.skipThisFunction = function(name) { return V8Profile.IC_RE.test(name); }; | 37 this.skipThisFunction = function(name) { return V8Profile.IC_RE.test(name); }; |
| 38 } | 38 } |
| 39 }; | 39 }; |
| 40 inherits(V8Profile, Profile); | 40 inherits(V8Profile, Profile); |
| 41 | 41 |
| 42 | 42 |
| 43 V8Profile.IC_RE = | 43 V8Profile.IC_RE = |
| 44 /^(?:CallIC|LoadIC|StoreIC)|(?:Builtin: (?:Keyed)?(?:Call|Load|Store)IC_)/; | 44 /^(?:CallIC|LoadIC|StoreIC)|(?:Builtin: (?:Keyed)?(?:Call|Load|Store)IC_)/; |
| 45 | 45 |
| 46 | 46 |
| 47 function ProfileMark(name, ticks, codeGenerated) { | |
| 48 this.name = name; | |
| 49 this.ticks = ticks; | |
| 50 this.codeGenerated = codeGenerated; | |
| 51 } | |
| 52 | |
| 53 | |
| 47 /** | 54 /** |
| 48 * A thin wrapper around shell's 'read' function showing a file name on error. | 55 * A thin wrapper around shell's 'read' function showing a file name on error. |
| 49 */ | 56 */ |
| 50 function readFile(fileName) { | 57 function readFile(fileName) { |
| 51 try { | 58 try { |
| 52 return read(fileName); | 59 return read(fileName); |
| 53 } catch (e) { | 60 } catch (e) { |
| 54 print(fileName + ': ' + (e.message || e)); | 61 print(fileName + ': ' + (e.message || e)); |
| 55 throw e; | 62 throw e; |
| 56 } | 63 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 parseInt, parseInt, 'var-args'], | 181 parseInt, parseInt, 'var-args'], |
| 175 processor: this.processTick }, | 182 processor: this.processTick }, |
| 176 'heap-sample-begin': { parsers: [null, null, parseInt], | 183 'heap-sample-begin': { parsers: [null, null, parseInt], |
| 177 processor: this.processHeapSampleBegin }, | 184 processor: this.processHeapSampleBegin }, |
| 178 'heap-sample-end': { parsers: [null, null], | 185 'heap-sample-end': { parsers: [null, null], |
| 179 processor: this.processHeapSampleEnd }, | 186 processor: this.processHeapSampleEnd }, |
| 180 'timer-event-start' : { parsers: [null, null, null], | 187 'timer-event-start' : { parsers: [null, null, null], |
| 181 processor: this.advanceDistortion }, | 188 processor: this.advanceDistortion }, |
| 182 'timer-event-end' : { parsers: [null, null, null], | 189 'timer-event-end' : { parsers: [null, null, null], |
| 183 processor: this.advanceDistortion }, | 190 processor: this.advanceDistortion }, |
| 191 'mark' : { parsers: [null], processor: this.processMark }, | |
| 184 // Ignored events. | 192 // Ignored events. |
| 185 'profiler': null, | 193 'profiler': null, |
| 186 'function-creation': null, | 194 'function-creation': null, |
| 187 'function-move': null, | 195 'function-move': null, |
| 188 'function-delete': null, | 196 'function-delete': null, |
| 189 'heap-sample-item': null, | 197 'heap-sample-item': null, |
| 190 // Obsolete row types. | 198 // Obsolete row types. |
| 191 'code-allocate': null, | 199 'code-allocate': null, |
| 192 'begin-code-region': null, | 200 'begin-code-region': null, |
| 193 'end-code-region': null }); | 201 'end-code-region': null }); |
| 194 | 202 |
| 195 this.cppEntriesProvider_ = cppEntriesProvider; | 203 this.cppEntriesProvider_ = cppEntriesProvider; |
| 196 this.callGraphSize_ = callGraphSize; | 204 this.callGraphSize_ = callGraphSize; |
| 197 this.ignoreUnknown_ = ignoreUnknown; | 205 this.ignoreUnknown_ = ignoreUnknown; |
| 198 this.stateFilter_ = stateFilter; | 206 this.stateFilter_ = stateFilter; |
| 199 this.snapshotLogProcessor_ = snapshotLogProcessor; | 207 this.snapshotLogProcessor_ = snapshotLogProcessor; |
| 200 this.sourceMap = sourceMap; | 208 this.sourceMap = sourceMap; |
| 201 this.deserializedEntriesNames_ = []; | 209 this.deserializedEntriesNames_ = []; |
| 202 var ticks = this.ticks_ = | 210 var ticks = this.ticks_ = |
| 203 { total: 0, unaccounted: 0, excluded: 0, gc: 0 }; | 211 { total: 0, unaccounted: 0, excluded: 0, states: [0, 0, 0, 0, 0, 0]}; |
| 212 this.codeGenerated_ = 0; | |
| 204 | 213 |
| 205 distortion = parseInt(distortion); | 214 distortion = parseInt(distortion); |
| 206 // Convert picoseconds to nanoseconds. | 215 // Convert picoseconds to nanoseconds. |
| 207 this.distortion_per_entry = isNaN(distortion) ? 0 : (distortion / 1000); | 216 this.distortion_per_entry = isNaN(distortion) ? 0 : (distortion / 1000); |
| 208 this.distortion = 0; | 217 this.distortion = 0; |
| 209 var rangelimits = range ? range.split(",") : []; | 218 var rangelimits = range ? range.split(",") : []; |
| 210 var range_start = parseInt(rangelimits[0]); | 219 var range_start = parseInt(rangelimits[0]); |
| 211 var range_end = parseInt(rangelimits[1]); | 220 var range_end = parseInt(rangelimits[1]); |
| 212 // Convert milliseconds to nanoseconds. | 221 // Convert milliseconds to nanoseconds. |
| 213 this.range_start = isNaN(range_start) ? -Infinity : (range_start * 1000); | 222 this.range_start = isNaN(range_start) ? -Infinity : (range_start * 1000); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 235 }; | 244 }; |
| 236 | 245 |
| 237 this.profile_ = new V8Profile(separateIc); | 246 this.profile_ = new V8Profile(separateIc); |
| 238 this.codeTypes_ = {}; | 247 this.codeTypes_ = {}; |
| 239 // Count each tick as a time unit. | 248 // Count each tick as a time unit. |
| 240 this.viewBuilder_ = new ViewBuilder(1); | 249 this.viewBuilder_ = new ViewBuilder(1); |
| 241 this.lastLogFileName_ = null; | 250 this.lastLogFileName_ = null; |
| 242 | 251 |
| 243 this.generation_ = 1; | 252 this.generation_ = 1; |
| 244 this.currentProducerProfile_ = null; | 253 this.currentProducerProfile_ = null; |
| 254 | |
| 255 this.marks_ = []; | |
| 245 }; | 256 }; |
| 246 inherits(TickProcessor, LogReader); | 257 inherits(TickProcessor, LogReader); |
| 247 | 258 |
| 248 | 259 |
| 249 TickProcessor.VmStates = { | 260 TickProcessor.VmStates = { |
| 261 FIRST: 0, | |
| 250 JS: 0, | 262 JS: 0, |
| 251 GC: 1, | 263 GC: 1, |
| 252 COMPILER: 2, | 264 COMPILER: 2, |
| 253 OTHER: 3, | 265 OTHER: 3, |
| 254 EXTERNAL: 4, | 266 EXTERNAL: 4, |
| 255 IDLE: 5 | 267 IDLE: 5, |
| 268 COUNT: 6 | |
| 256 }; | 269 }; |
| 257 | 270 |
| 258 | 271 |
| 259 TickProcessor.CodeTypes = { | 272 TickProcessor.CodeTypes = { |
| 260 CPP: 0, | 273 CPP: 0, |
| 261 SHARED_LIB: 1 | 274 SHARED_LIB: 1 |
| 262 }; | 275 }; |
| 263 // Otherwise, this is JS-related code. We are not adding it to | 276 // Otherwise, this is JS-related code. We are not adding it to |
| 264 // codeTypes_ map because there can be zillions of them. | 277 // codeTypes_ map because there can be zillions of them. |
| 265 | 278 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 295 return !(name in this.codeTypes_); | 308 return !(name in this.codeTypes_); |
| 296 }; | 309 }; |
| 297 | 310 |
| 298 | 311 |
| 299 TickProcessor.prototype.processLogFile = function(fileName) { | 312 TickProcessor.prototype.processLogFile = function(fileName) { |
| 300 this.lastLogFileName_ = fileName; | 313 this.lastLogFileName_ = fileName; |
| 301 var line; | 314 var line; |
| 302 while (line = readline()) { | 315 while (line = readline()) { |
| 303 this.processLogLine(line); | 316 this.processLogLine(line); |
| 304 } | 317 } |
| 318 // If marks are present add a final marker. | |
| 319 if (this.marks_.length > 0) { | |
| 320 this.processMark("<end of log file>"); | |
| 321 } | |
| 305 }; | 322 }; |
| 306 | 323 |
| 307 | 324 |
| 308 TickProcessor.prototype.processLogFileInTest = function(fileName) { | 325 TickProcessor.prototype.processLogFileInTest = function(fileName) { |
| 309 // Hack file name to avoid dealing with platform specifics. | 326 // Hack file name to avoid dealing with platform specifics. |
| 310 this.lastLogFileName_ = 'v8.log'; | 327 this.lastLogFileName_ = 'v8.log'; |
| 311 var contents = readFile(fileName); | 328 var contents = readFile(fileName); |
| 312 this.processLogChunk(contents); | 329 this.processLogChunk(contents); |
| 313 }; | 330 }; |
| 314 | 331 |
| 315 | 332 |
| 316 TickProcessor.prototype.processSharedLibrary = function( | 333 TickProcessor.prototype.processSharedLibrary = function( |
| 317 name, startAddr, endAddr) { | 334 name, startAddr, endAddr) { |
| 318 var entry = this.profile_.addLibrary(name, startAddr, endAddr); | 335 var entry = this.profile_.addLibrary(name, startAddr, endAddr); |
| 319 this.setCodeType(entry.getName(), 'SHARED_LIB'); | 336 this.setCodeType(entry.getName(), 'SHARED_LIB'); |
| 320 | 337 |
| 321 var self = this; | 338 var self = this; |
| 322 var libFuncs = this.cppEntriesProvider_.parseVmSymbols( | 339 var libFuncs = this.cppEntriesProvider_.parseVmSymbols( |
| 323 name, startAddr, endAddr, function(fName, fStart, fEnd) { | 340 name, startAddr, endAddr, function(fName, fStart, fEnd) { |
| 324 self.profile_.addStaticCode(fName, fStart, fEnd); | 341 self.profile_.addStaticCode(fName, fStart, fEnd); |
| 325 self.setCodeType(fName, 'CPP'); | 342 self.setCodeType(fName, 'CPP'); |
| 326 }); | 343 }); |
| 327 }; | 344 }; |
| 328 | 345 |
| 329 | 346 |
| 330 TickProcessor.prototype.processCodeCreation = function( | 347 TickProcessor.prototype.processCodeCreation = function( |
| 331 type, kind, start, size, name, maybe_func) { | 348 type, kind, start, size, name, maybe_func) { |
| 349 this.codeGenerated_ += size; | |
| 332 name = this.deserializedEntriesNames_[start] || name; | 350 name = this.deserializedEntriesNames_[start] || name; |
| 333 if (maybe_func.length) { | 351 if (maybe_func.length) { |
| 334 var funcAddr = parseInt(maybe_func[0]); | 352 var funcAddr = parseInt(maybe_func[0]); |
| 335 var state = parseState(maybe_func[1]); | 353 var state = parseState(maybe_func[1]); |
| 336 this.profile_.addFuncCode(type, name, start, size, funcAddr, state); | 354 this.profile_.addFuncCode(type, name, start, size, funcAddr, state); |
| 337 } else { | 355 } else { |
| 338 this.profile_.addCode(type, name, start, size); | 356 this.profile_.addCode(type, name, start, size); |
| 339 } | 357 } |
| 340 }; | 358 }; |
| 341 | 359 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 372 is_external_callback, | 390 is_external_callback, |
| 373 tos_or_external_callback, | 391 tos_or_external_callback, |
| 374 vmState, | 392 vmState, |
| 375 stack) { | 393 stack) { |
| 376 this.distortion += this.distortion_per_entry; | 394 this.distortion += this.distortion_per_entry; |
| 377 ns_since_start -= this.distortion; | 395 ns_since_start -= this.distortion; |
| 378 if (ns_since_start < this.range_start || ns_since_start > this.range_end) { | 396 if (ns_since_start < this.range_start || ns_since_start > this.range_end) { |
| 379 return; | 397 return; |
| 380 } | 398 } |
| 381 this.ticks_.total++; | 399 this.ticks_.total++; |
| 382 if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++; | 400 this.ticks_.states[vmState]++; |
| 383 if (!this.includeTick(vmState)) { | 401 if (!this.includeTick(vmState)) { |
| 384 this.ticks_.excluded++; | 402 this.ticks_.excluded++; |
| 385 return; | 403 return; |
| 386 } | 404 } |
| 387 if (is_external_callback) { | 405 if (is_external_callback) { |
| 388 // Don't use PC when in external callback code, as it can point | 406 // Don't use PC when in external callback code, as it can point |
| 389 // inside callback's code, and we will erroneously report | 407 // inside callback's code, and we will erroneously report |
| 390 // that a callback calls itself. Instead we use tos_or_external_callback, | 408 // that a callback calls itself. Instead we use tos_or_external_callback, |
| 391 // as simply resetting PC will produce unaccounted ticks. | 409 // as simply resetting PC will produce unaccounted ticks. |
| 392 pc = tos_or_external_callback; | 410 pc = tos_or_external_callback; |
| 393 tos_or_external_callback = 0; | 411 tos_or_external_callback = 0; |
| 394 } else if (tos_or_external_callback) { | 412 } else if (tos_or_external_callback) { |
| 395 // Find out, if top of stack was pointing inside a JS function | 413 // Find out, if top of stack was pointing inside a JS function |
| 396 // meaning that we have encountered a frameless invocation. | 414 // meaning that we have encountered a frameless invocation. |
| 397 var funcEntry = this.profile_.findEntry(tos_or_external_callback); | 415 var funcEntry = this.profile_.findEntry(tos_or_external_callback); |
| 398 if (!funcEntry || !funcEntry.isJSFunction || !funcEntry.isJSFunction()) { | 416 if (!funcEntry || !funcEntry.isJSFunction || !funcEntry.isJSFunction()) { |
| 399 tos_or_external_callback = 0; | 417 tos_or_external_callback = 0; |
| 400 } | 418 } |
| 401 } | 419 } |
| 402 | 420 |
| 403 this.profile_.recordTick(this.processStack(pc, tos_or_external_callback, stack )); | 421 this.profile_.recordTick(this.processStack(pc, tos_or_external_callback, stack )); |
| 404 }; | 422 }; |
| 405 | 423 |
| 406 | 424 |
| 425 TickProcessor.prototype.processMark = function(name) { | |
| 426 this.marks_.push( | |
| 427 new ProfileMark(name, this.ticks_.total, this.codeGenerated_)); | |
| 428 } | |
| 429 | |
| 430 | |
| 407 TickProcessor.prototype.advanceDistortion = function() { | 431 TickProcessor.prototype.advanceDistortion = function() { |
| 408 this.distortion += this.distortion_per_entry; | 432 this.distortion += this.distortion_per_entry; |
| 409 } | 433 } |
| 410 | 434 |
| 411 | 435 |
| 412 TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) { | 436 TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) { |
| 413 if (space != 'Heap') return; | 437 if (space != 'Heap') return; |
| 414 this.currentProducerProfile_ = new CallTree(); | 438 this.currentProducerProfile_ = new CallTree(); |
| 415 }; | 439 }; |
| 416 | 440 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 function(name) { return self.isSharedLibrary(name); }); | 499 function(name) { return self.isSharedLibrary(name); }); |
| 476 | 500 |
| 477 this.printHeader('JavaScript'); | 501 this.printHeader('JavaScript'); |
| 478 this.printEntries(flatViewNodes, nonLibraryTicks, | 502 this.printEntries(flatViewNodes, nonLibraryTicks, |
| 479 function(name) { return self.isJsCode(name); }); | 503 function(name) { return self.isJsCode(name); }); |
| 480 | 504 |
| 481 this.printHeader('C++'); | 505 this.printHeader('C++'); |
| 482 this.printEntries(flatViewNodes, nonLibraryTicks, | 506 this.printEntries(flatViewNodes, nonLibraryTicks, |
| 483 function(name) { return self.isCppCode(name); }); | 507 function(name) { return self.isCppCode(name); }); |
| 484 | 508 |
| 485 this.printHeader('GC'); | 509 this.printTicksListHeader('States', 20); |
| 486 this.printCounter(this.ticks_.gc, totalTicks); | 510 var vmStateNames = [ |
| 511 "JavaScript", | |
| 512 "GC", | |
| 513 "Compiler", | |
| 514 "Other", | |
| 515 "External", | |
| 516 "Idle" | |
| 517 ]; | |
| 518 | |
| 519 for (var state = TickProcessor.VmStates.FIRST; | |
| 520 state < TickProcessor.VmStates.COUNT; | |
| 521 state++) { | |
| 522 if (this.stateFilter_ == null || this.stateFilter_ == state) { | |
| 523 this.printLabledCounter( | |
| 524 vmStateNames[state], this.ticks_.states[state], totalTicks); | |
| 525 } | |
| 526 } | |
| 487 | 527 |
| 488 this.printHeavyProfHeader(); | 528 this.printHeavyProfHeader(); |
| 489 var heavyProfile = this.profile_.getBottomUpProfile(); | 529 var heavyProfile = this.profile_.getBottomUpProfile(); |
| 490 var heavyView = this.viewBuilder_.buildView(heavyProfile); | 530 var heavyView = this.viewBuilder_.buildView(heavyProfile); |
| 491 // To show the same percentages as in the flat profile. | 531 // To show the same percentages as in the flat profile. |
| 492 heavyView.head.totalTime = totalTicks; | 532 heavyView.head.totalTime = totalTicks; |
| 493 // Sort by total time, desc, then by name, desc. | 533 // Sort by total time, desc, then by name, desc. |
| 494 heavyView.sort(function(rec1, rec2) { | 534 heavyView.sort(function(rec1, rec2) { |
| 495 return rec2.totalTime - rec1.totalTime || | 535 return rec2.totalTime - rec1.totalTime || |
| 496 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); | 536 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); |
| 497 this.printHeavyProfile(heavyView.head.children); | 537 this.printHeavyProfile(heavyView.head.children); |
| 538 | |
| 539 if (this.marks_.length > 0) { | |
| 540 var maxLength = 0; | |
| 541 this.marks_.forEach(function (mark) { | |
| 542 maxLength = Math.max(maxLength, mark.name.length); | |
| 543 }); | |
| 544 print(' [Marks]'); | |
| 545 print(' ' + padRight('Name', 20) + | |
| 546 ' ' + padLeft('Ticks', 6) + | |
|
Yang
2013/09/30 11:25:02
Please align those lines like the print below.
| |
| 547 ' ' + padLeft('Delta', 6) + | |
| 548 ' ' + padLeft('Code (kb)', 10) + | |
| 549 ' ' + padLeft('Delta (kb)', 11)); | |
| 550 var lastTicks = 0; | |
| 551 var lastCodeGenerated = 0; | |
| 552 this.marks_.forEach(function (mark) { | |
| 553 var ticksDelta = mark.ticks - lastTicks; | |
| 554 var codeGeneratedDelta = | |
| 555 Math.round((mark.codeGenerated - lastCodeGenerated) / 1024); | |
| 556 print(' ' + padRight(mark.name, 20) + | |
| 557 ' ' + padLeft(mark.ticks, 6) + | |
| 558 ' ' + padLeft(ticksDelta, 6) + | |
| 559 ' ' + padLeft(Math.round(mark.codeGenerated / 1024), 10) + | |
| 560 ' ' + padLeft(codeGeneratedDelta, 11)); | |
| 561 lastTicks = mark.ticks; | |
| 562 lastCodeGenerated = mark.codeGenerated; | |
| 563 }); | |
| 564 } | |
| 565 | |
| 566 print(' [Code statistics]'); | |
| 567 var generatedCode = Math.round(this.profile_.generatedCode / 1024); | |
| 568 print(' Generated code: ' + generatedCode + ' kb'); | |
| 498 }; | 569 }; |
| 499 | 570 |
| 500 | 571 |
| 501 function padLeft(s, len) { | 572 function padLeft(s, len) { |
| 502 s = s.toString(); | 573 s = s.toString(); |
| 503 if (s.length < len) { | 574 if (s.length < len) { |
| 504 var padLength = len - s.length; | 575 var padLength = len - s.length; |
| 505 if (!(padLength in padLeft)) { | 576 if (!(padLength in padLeft)) { |
| 506 padLeft[padLength] = new Array(padLength + 1).join(' '); | 577 padLeft[padLength] = new Array(padLength + 1).join(' '); |
| 507 } | 578 } |
| 508 s = padLeft[padLength] + s; | 579 s = padLeft[padLength] + s; |
| 509 } | 580 } |
| 510 return s; | 581 return s; |
| 511 }; | 582 }; |
| 512 | 583 |
| 513 | 584 |
| 585 function padRight(s, len) { | |
| 586 s = s.toString(); | |
| 587 if (s.length < len) { | |
| 588 s = s + (new Array(len - s.length + 1).join(' ')); | |
| 589 } | |
| 590 return s; | |
| 591 } | |
| 592 | |
| 593 | |
| 514 TickProcessor.prototype.printHeader = function(headerTitle) { | 594 TickProcessor.prototype.printHeader = function(headerTitle) { |
| 515 print('\n [' + headerTitle + ']:'); | 595 print('\n [' + headerTitle + ']:'); |
| 516 print(' ticks total nonlib name'); | 596 print(' ticks total nonlib name'); |
| 517 }; | 597 }; |
| 518 | 598 |
| 519 | 599 |
| 600 TickProcessor.prototype.printTicksListHeader = function(headerTitle, padding) { | |
| 601 print('\n [' + headerTitle + ']:'); | |
| 602 print(' ' + padRight('category', padding) + ' ticks percentage'); | |
| 603 }; | |
| 604 | |
| 605 | |
| 520 TickProcessor.prototype.printHeavyProfHeader = function() { | 606 TickProcessor.prototype.printHeavyProfHeader = function() { |
| 521 print('\n [Bottom up (heavy) profile]:'); | 607 print('\n [Bottom up (heavy) profile]:'); |
| 522 print(' Note: percentage shows a share of a particular caller in the ' + | 608 print(' Note: percentage shows a share of a particular caller in the ' + |
| 523 'total\n' + | 609 'total\n' + |
| 524 ' amount of its parent calls.'); | 610 ' amount of its parent calls.'); |
| 525 print(' Callers occupying less than ' + | 611 print(' Callers occupying less than ' + |
| 526 TickProcessor.CALL_PROFILE_CUTOFF_PCT.toFixed(1) + | 612 TickProcessor.CALL_PROFILE_CUTOFF_PCT.toFixed(1) + |
| 527 '% are not shown.\n'); | 613 '% are not shown.\n'); |
| 528 print(' ticks parent name'); | 614 print(' ticks parent name'); |
| 529 }; | 615 }; |
| 530 | 616 |
| 531 | 617 |
| 532 TickProcessor.prototype.printCounter = function(ticksCount, totalTicksCount) { | 618 TickProcessor.prototype.printCounter = function(ticksCount, totalTicksCount) { |
| 533 var pct = ticksCount * 100.0 / totalTicksCount; | 619 var pct = ticksCount * 100.0 / totalTicksCount; |
| 534 print(' ' + padLeft(ticksCount, 5) + ' ' + padLeft(pct.toFixed(1), 5) + '%') ; | 620 print(' ' + padLeft(ticksCount, 5) + ' ' + padLeft(pct.toFixed(1), 5) + '%') ; |
| 535 }; | 621 }; |
| 536 | 622 |
| 537 | 623 |
| 624 TickProcessor.prototype.printLabledCounter = function( | |
| 625 label, ticksCount, totalTicksCount) { | |
| 626 var pct = ticksCount * 100.0 / totalTicksCount; | |
| 627 print(' ' + padRight(label, 20) + ' ' + | |
| 628 padLeft(ticksCount, 5) + ' ' + | |
| 629 padLeft(pct.toFixed(1), 10) + '%'); | |
| 630 }; | |
| 631 | |
| 632 | |
| 538 TickProcessor.prototype.processProfile = function( | 633 TickProcessor.prototype.processProfile = function( |
| 539 profile, filterP, func) { | 634 profile, filterP, func) { |
| 540 for (var i = 0, n = profile.length; i < n; ++i) { | 635 for (var i = 0, n = profile.length; i < n; ++i) { |
| 541 var rec = profile[i]; | 636 var rec = profile[i]; |
| 542 if (!filterP(rec.internalFuncName)) { | 637 if (!filterP(rec.internalFuncName)) { |
| 543 continue; | 638 continue; |
| 544 } | 639 } |
| 545 func(rec); | 640 func(rec); |
| 546 } | 641 } |
| 547 }; | 642 }; |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 918 }; | 1013 }; |
| 919 | 1014 |
| 920 | 1015 |
| 921 ArgumentsProcessor.prototype.result = function() { | 1016 ArgumentsProcessor.prototype.result = function() { |
| 922 return this.result_; | 1017 return this.result_; |
| 923 }; | 1018 }; |
| 924 | 1019 |
| 925 | 1020 |
| 926 ArgumentsProcessor.prototype.printUsageAndExit = function() { | 1021 ArgumentsProcessor.prototype.printUsageAndExit = function() { |
| 927 | 1022 |
| 928 function padRight(s, len) { | |
| 929 s = s.toString(); | |
| 930 if (s.length < len) { | |
| 931 s = s + (new Array(len - s.length + 1).join(' ')); | |
| 932 } | |
| 933 return s; | |
| 934 } | |
| 935 | |
| 936 print('Cmdline args: [options] [log-file-name]\n' + | 1023 print('Cmdline args: [options] [log-file-name]\n' + |
| 937 'Default log file name is "' + | 1024 'Default log file name is "' + |
| 938 ArgumentsProcessor.DEFAULTS.logFileName + '".\n'); | 1025 ArgumentsProcessor.DEFAULTS.logFileName + '".\n'); |
| 939 print('Options:'); | 1026 print('Options:'); |
| 940 for (var arg in this.argsDispatch_) { | 1027 for (var arg in this.argsDispatch_) { |
| 941 var synonims = [arg]; | 1028 var synonims = [arg]; |
| 942 var dispatch = this.argsDispatch_[arg]; | 1029 var dispatch = this.argsDispatch_[arg]; |
| 943 for (var synArg in this.argsDispatch_) { | 1030 for (var synArg in this.argsDispatch_) { |
| 944 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { | 1031 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { |
| 945 synonims.push(synArg); | 1032 synonims.push(synArg); |
| 946 delete this.argsDispatch_[synArg]; | 1033 delete this.argsDispatch_[synArg]; |
| 947 } | 1034 } |
| 948 } | 1035 } |
| 949 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); | 1036 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]); |
| 950 } | 1037 } |
| 951 quit(2); | 1038 quit(2); |
| 952 }; | 1039 }; |
| 953 | |
| OLD | NEW |