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

Side by Side Diff: tools/tickprocessor.js

Issue 155137: Revert r2372 to get the tree green again. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 5 months 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 | « tools/linux-tick-processor ('k') | tools/tickprocessor-driver.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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 heavyView.sort(function(rec1, rec2) { 281 heavyView.sort(function(rec1, rec2) {
282 return rec2.totalTime - rec1.totalTime || 282 return rec2.totalTime - rec1.totalTime ||
283 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); }); 283 (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); });
284 this.printHeavyProfile(heavyView.head.children); 284 this.printHeavyProfile(heavyView.head.children);
285 }; 285 };
286 286
287 287
288 function padLeft(s, len) { 288 function padLeft(s, len) {
289 s = s.toString(); 289 s = s.toString();
290 if (s.length < len) { 290 if (s.length < len) {
291 var padLength = len - s.length; 291 s = (new Array(len - s.length + 1).join(' ')) + s;
292 if (!(padLength in padLeft)) {
293 padLeft[padLength] = new Array(padLength + 1).join(' ');
294 }
295 s = padLeft[padLength] + s;
296 } 292 }
297 return s; 293 return s;
298 }; 294 };
299 295
300 296
301 TickProcessor.prototype.printHeader = function(headerTitle) { 297 TickProcessor.prototype.printHeader = function(headerTitle) {
302 print('\n [' + headerTitle + ']:'); 298 print('\n [' + headerTitle + ']:');
303 print(' ticks total nonlib name'); 299 print(' ticks total nonlib name');
304 }; 300 };
305 301
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 WindowsCppEntriesProvider.prototype.unmangleName = function(name) { 504 WindowsCppEntriesProvider.prototype.unmangleName = function(name) {
509 // Empty or non-mangled name. 505 // Empty or non-mangled name.
510 if (name.length < 1 || name.charAt(0) != '?') return name; 506 if (name.length < 1 || name.charAt(0) != '?') return name;
511 var nameEndPos = name.indexOf('@@'); 507 var nameEndPos = name.indexOf('@@');
512 var components = name.substring(1, nameEndPos).split('@'); 508 var components = name.substring(1, nameEndPos).split('@');
513 components.reverse(); 509 components.reverse();
514 return components.join('::'); 510 return components.join('::');
515 }; 511 };
516 512
517 513
518 function ArgumentsProcessor(args) { 514 function padRight(s, len) {
519 this.args_ = args; 515 s = s.toString();
520 this.result_ = ArgumentsProcessor.DEFAULTS; 516 if (s.length < len) {
517 s = s + (new Array(len - s.length + 1).join(' '));
518 }
519 return s;
520 };
521 521
522 this.argsDispatch_ = { 522
523 function processArguments(args) {
524 var result = {
525 logFileName: 'v8.log',
526 platform: 'unix',
527 stateFilter: null,
528 ignoreUnknown: false,
529 separateIc: false,
530 nm: 'nm'
531 };
532 var argsDispatch = {
523 '-j': ['stateFilter', TickProcessor.VmStates.JS, 533 '-j': ['stateFilter', TickProcessor.VmStates.JS,
524 'Show only ticks from JS VM state'], 534 'Show only ticks from JS VM state'],
525 '-g': ['stateFilter', TickProcessor.VmStates.GC, 535 '-g': ['stateFilter', TickProcessor.VmStates.GC,
526 'Show only ticks from GC VM state'], 536 'Show only ticks from GC VM state'],
527 '-c': ['stateFilter', TickProcessor.VmStates.COMPILER, 537 '-c': ['stateFilter', TickProcessor.VmStates.COMPILER,
528 'Show only ticks from COMPILER VM state'], 538 'Show only ticks from COMPILER VM state'],
529 '-o': ['stateFilter', TickProcessor.VmStates.OTHER, 539 '-o': ['stateFilter', TickProcessor.VmStates.OTHER,
530 'Show only ticks from OTHER VM state'], 540 'Show only ticks from OTHER VM state'],
531 '-e': ['stateFilter', TickProcessor.VmStates.EXTERNAL, 541 '-e': ['stateFilter', TickProcessor.VmStates.EXTERNAL,
532 'Show only ticks from EXTERNAL VM state'], 542 'Show only ticks from EXTERNAL VM state'],
533 '--ignore-unknown': ['ignoreUnknown', true, 543 '--ignore-unknown': ['ignoreUnknown', true,
534 'Exclude ticks of unknown code entries from processing'], 544 'Exclude ticks of unknown code entries from processing'],
535 '--separate-ic': ['separateIc', true, 545 '--separate-ic': ['separateIc', true,
536 'Separate IC entries'], 546 'Separate IC entries'],
537 '--unix': ['platform', 'unix', 547 '--unix': ['platform', 'unix',
538 'Specify that we are running on *nix platform'], 548 'Specify that we are running on *nix platform'],
539 '--windows': ['platform', 'windows', 549 '--windows': ['platform', 'windows',
540 'Specify that we are running on Windows platform'], 550 'Specify that we are running on Windows platform'],
541 '--nm': ['nm', 'nm', 551 '--nm': ['nm', 'nm',
542 'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)'] 552 'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)']
543 }; 553 };
544 this.argsDispatch_['--js'] = this.argsDispatch_['-j']; 554 argsDispatch['--js'] = argsDispatch['-j'];
545 this.argsDispatch_['--gc'] = this.argsDispatch_['-g']; 555 argsDispatch['--gc'] = argsDispatch['-g'];
546 this.argsDispatch_['--compiler'] = this.argsDispatch_['-c']; 556 argsDispatch['--compiler'] = argsDispatch['-c'];
547 this.argsDispatch_['--other'] = this.argsDispatch_['-o']; 557 argsDispatch['--other'] = argsDispatch['-o'];
548 this.argsDispatch_['--external'] = this.argsDispatch_['-e']; 558 argsDispatch['--external'] = argsDispatch['-e'];
549 };
550 559
560 function printUsageAndExit() {
561 print('Cmdline args: [options] [log-file-name]\n' +
562 'Default log file name is "v8.log".\n');
563 print('Options:');
564 for (var arg in argsDispatch) {
565 var synonims = [arg];
566 var dispatch = argsDispatch[arg];
567 for (var synArg in argsDispatch) {
568 if (arg !== synArg && dispatch === argsDispatch[synArg]) {
569 synonims.push(synArg);
570 delete argsDispatch[synArg];
571 }
572 }
573 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]);
574 }
575 quit(2);
576 }
551 577
552 ArgumentsProcessor.DEFAULTS = { 578 while (args.length) {
553 logFileName: 'v8.log', 579 var arg = args[0];
554 platform: 'unix',
555 stateFilter: null,
556 ignoreUnknown: false,
557 separateIc: false,
558 nm: 'nm'
559 };
560
561
562 ArgumentsProcessor.prototype.parse = function() {
563 while (this.args_.length) {
564 var arg = this.args_[0];
565 if (arg.charAt(0) != '-') { 580 if (arg.charAt(0) != '-') {
566 break; 581 break;
567 } 582 }
568 this.args_.shift(); 583 args.shift();
569 var userValue = null; 584 var userValue = null;
570 var eqPos = arg.indexOf('='); 585 var eqPos = arg.indexOf('=');
571 if (eqPos != -1) { 586 if (eqPos != -1) {
572 userValue = arg.substr(eqPos + 1); 587 userValue = arg.substr(eqPos + 1);
573 arg = arg.substr(0, eqPos); 588 arg = arg.substr(0, eqPos);
574 } 589 }
575 if (arg in this.argsDispatch_) { 590 if (arg in argsDispatch) {
576 var dispatch = this.argsDispatch_[arg]; 591 var dispatch = argsDispatch[arg];
577 this.result_[dispatch[0]] = userValue == null ? dispatch[1] : userValue; 592 result[dispatch[0]] = userValue == null ? dispatch[1] : userValue;
578 } else { 593 } else {
579 return false; 594 printUsageAndExit();
580 } 595 }
581 } 596 }
582 597
583 if (this.args_.length >= 1) { 598 if (args.length >= 1) {
584 this.result_.logFileName = this.args_.shift(); 599 result.logFileName = args.shift();
585 } 600 }
586 return true; 601 return result;
587 }; 602 };
588 603
589 604
590 ArgumentsProcessor.prototype.result = function() { 605 var params = processArguments(arguments);
591 return this.result_; 606 var tickProcessor = new TickProcessor(
592 }; 607 params.platform == 'unix' ? new UnixCppEntriesProvider(params.nm) :
593 608 new WindowsCppEntriesProvider(),
594 609 params.separateIc,
595 ArgumentsProcessor.prototype.printUsageAndExit = function() { 610 params.ignoreUnknown,
596 611 params.stateFilter);
597 function padRight(s, len) { 612 tickProcessor.processLogFile(params.logFileName);
598 s = s.toString(); 613 tickProcessor.printStatistics();
599 if (s.length < len) {
600 s = s + (new Array(len - s.length + 1).join(' '));
601 }
602 return s;
603 }
604
605 print('Cmdline args: [options] [log-file-name]\n' +
606 'Default log file name is "' +
607 ArgumentsProcessor.DEFAULTS.logFileName + '".\n');
608 print('Options:');
609 for (var arg in this.argsDispatch_) {
610 var synonims = [arg];
611 var dispatch = this.argsDispatch_[arg];
612 for (var synArg in this.argsDispatch_) {
613 if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) {
614 synonims.push(synArg);
615 delete this.argsDispatch_[synArg];
616 }
617 }
618 print(' ' + padRight(synonims.join(', '), 20) + dispatch[2]);
619 }
620 quit(2);
621 };
622
OLDNEW
« no previous file with comments | « tools/linux-tick-processor ('k') | tools/tickprocessor-driver.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698