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

Side by Side Diff: tools/tickprocessor.js

Issue 155161: Add automatic tests for Tick Processor, take two. (Closed)
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
« no previous file with comments | « tools/test.py ('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 s = (new Array(len - s.length + 1).join(' ')) + s; 291 var padLength = len - s.length;
292 if (!(padLength in padLeft)) {
293 padLeft[padLength] = new Array(padLength + 1).join(' ');
294 }
295 s = padLeft[padLength] + s;
292 } 296 }
293 return s; 297 return s;
294 }; 298 };
295 299
296 300
297 TickProcessor.prototype.printHeader = function(headerTitle) { 301 TickProcessor.prototype.printHeader = function(headerTitle) {
298 print('\n [' + headerTitle + ']:'); 302 print('\n [' + headerTitle + ']:');
299 print(' ticks total nonlib name'); 303 print(' ticks total nonlib name');
300 }; 304 };
301 305
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 WindowsCppEntriesProvider.prototype.unmangleName = function(name) { 508 WindowsCppEntriesProvider.prototype.unmangleName = function(name) {
505 // Empty or non-mangled name. 509 // Empty or non-mangled name.
506 if (name.length < 1 || name.charAt(0) != '?') return name; 510 if (name.length < 1 || name.charAt(0) != '?') return name;
507 var nameEndPos = name.indexOf('@@'); 511 var nameEndPos = name.indexOf('@@');
508 var components = name.substring(1, nameEndPos).split('@'); 512 var components = name.substring(1, nameEndPos).split('@');
509 components.reverse(); 513 components.reverse();
510 return components.join('::'); 514 return components.join('::');
511 }; 515 };
512 516
513 517
514 function padRight(s, len) { 518 function ArgumentsProcessor(args) {
515 s = s.toString(); 519 this.args_ = args;
516 if (s.length < len) { 520 this.result_ = ArgumentsProcessor.DEFAULTS;
517 s = s + (new Array(len - s.length + 1).join(' '));
518 }
519 return s;
520 };
521 521
522 522 this.argsDispatch_ = {
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 = {
533 '-j': ['stateFilter', TickProcessor.VmStates.JS, 523 '-j': ['stateFilter', TickProcessor.VmStates.JS,
534 'Show only ticks from JS VM state'], 524 'Show only ticks from JS VM state'],
535 '-g': ['stateFilter', TickProcessor.VmStates.GC, 525 '-g': ['stateFilter', TickProcessor.VmStates.GC,
536 'Show only ticks from GC VM state'], 526 'Show only ticks from GC VM state'],
537 '-c': ['stateFilter', TickProcessor.VmStates.COMPILER, 527 '-c': ['stateFilter', TickProcessor.VmStates.COMPILER,
538 'Show only ticks from COMPILER VM state'], 528 'Show only ticks from COMPILER VM state'],
539 '-o': ['stateFilter', TickProcessor.VmStates.OTHER, 529 '-o': ['stateFilter', TickProcessor.VmStates.OTHER,
540 'Show only ticks from OTHER VM state'], 530 'Show only ticks from OTHER VM state'],
541 '-e': ['stateFilter', TickProcessor.VmStates.EXTERNAL, 531 '-e': ['stateFilter', TickProcessor.VmStates.EXTERNAL,
542 'Show only ticks from EXTERNAL VM state'], 532 'Show only ticks from EXTERNAL VM state'],
543 '--ignore-unknown': ['ignoreUnknown', true, 533 '--ignore-unknown': ['ignoreUnknown', true,
544 'Exclude ticks of unknown code entries from processing'], 534 'Exclude ticks of unknown code entries from processing'],
545 '--separate-ic': ['separateIc', true, 535 '--separate-ic': ['separateIc', true,
546 'Separate IC entries'], 536 'Separate IC entries'],
547 '--unix': ['platform', 'unix', 537 '--unix': ['platform', 'unix',
548 'Specify that we are running on *nix platform'], 538 'Specify that we are running on *nix platform'],
549 '--windows': ['platform', 'windows', 539 '--windows': ['platform', 'windows',
550 'Specify that we are running on Windows platform'], 540 'Specify that we are running on Windows platform'],
551 '--nm': ['nm', 'nm', 541 '--nm': ['nm', 'nm',
552 'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)'] 542 'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)']
553 }; 543 };
554 argsDispatch['--js'] = argsDispatch['-j']; 544 this.argsDispatch_['--js'] = this.argsDispatch_['-j'];
555 argsDispatch['--gc'] = argsDispatch['-g']; 545 this.argsDispatch_['--gc'] = this.argsDispatch_['-g'];
556 argsDispatch['--compiler'] = argsDispatch['-c']; 546 this.argsDispatch_['--compiler'] = this.argsDispatch_['-c'];
557 argsDispatch['--other'] = argsDispatch['-o']; 547 this.argsDispatch_['--other'] = this.argsDispatch_['-o'];
558 argsDispatch['--external'] = argsDispatch['-e']; 548 this.argsDispatch_['--external'] = this.argsDispatch_['-e'];
549 };
559 550
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 }
577 551
578 while (args.length) { 552 ArgumentsProcessor.DEFAULTS = {
579 var arg = args[0]; 553 logFileName: 'v8.log',
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];
580 if (arg.charAt(0) != '-') { 565 if (arg.charAt(0) != '-') {
581 break; 566 break;
582 } 567 }
583 args.shift(); 568 this.args_.shift();
584 var userValue = null; 569 var userValue = null;
585 var eqPos = arg.indexOf('='); 570 var eqPos = arg.indexOf('=');
586 if (eqPos != -1) { 571 if (eqPos != -1) {
587 userValue = arg.substr(eqPos + 1); 572 userValue = arg.substr(eqPos + 1);
588 arg = arg.substr(0, eqPos); 573 arg = arg.substr(0, eqPos);
589 } 574 }
590 if (arg in argsDispatch) { 575 if (arg in this.argsDispatch_) {
591 var dispatch = argsDispatch[arg]; 576 var dispatch = this.argsDispatch_[arg];
592 result[dispatch[0]] = userValue == null ? dispatch[1] : userValue; 577 this.result_[dispatch[0]] = userValue == null ? dispatch[1] : userValue;
593 } else { 578 } else {
594 printUsageAndExit(); 579 return false;
595 } 580 }
596 } 581 }
597 582
598 if (args.length >= 1) { 583 if (this.args_.length >= 1) {
599 result.logFileName = args.shift(); 584 this.result_.logFileName = this.args_.shift();
600 } 585 }
601 return result; 586 return true;
602 }; 587 };
603 588
604 589
605 var params = processArguments(arguments); 590 ArgumentsProcessor.prototype.result = function() {
606 var tickProcessor = new TickProcessor( 591 return this.result_;
607 params.platform == 'unix' ? new UnixCppEntriesProvider(params.nm) : 592 };
608 new WindowsCppEntriesProvider(), 593
609 params.separateIc, 594
610 params.ignoreUnknown, 595 ArgumentsProcessor.prototype.printUsageAndExit = function() {
611 params.stateFilter); 596
612 tickProcessor.processLogFile(params.logFileName); 597 function padRight(s, len) {
613 tickProcessor.printStatistics(); 598 s = s.toString();
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/test.py ('k') | tools/tickprocessor-driver.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698