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

Side by Side Diff: tools/binary_size/run_binary_size_analysis.py

Issue 399683004: binarysize tool: Cleaning up some progress output. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added empty line Created 6 years, 3 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 | « build/android/pylib/symbols/elf_symbolizer.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Generate a spatial analysis against an arbitrary library. 6 """Generate a spatial analysis against an arbitrary library.
7 7
8 To use, build the 'binary_size_tool' target. Then run this tool, passing 8 To use, build the 'binary_size_tool' target. Then run this tool, passing
9 in the location of the library to be analyzed along with any other options 9 in the location of the library to be analyzed along with any other options
10 you desire. 10 you desire.
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 speed = 0 534 speed = 0
535 progress_percent = (100.0 * (progress.count + progress.skip_count) / 535 progress_percent = (100.0 * (progress.count + progress.skip_count) /
536 nm_output_lines_len) 536 nm_output_lines_len)
537 disambiguation_percent = 0 537 disambiguation_percent = 0
538 if progress.disambiguations != 0: 538 if progress.disambiguations != 0:
539 disambiguation_percent = (100.0 * progress.disambiguations / 539 disambiguation_percent = (100.0 * progress.disambiguations /
540 progress.was_ambiguous) 540 progress.was_ambiguous)
541 541
542 sys.stdout.write('\r%.1f%%: Looked up %d symbols (%d collisions, ' 542 sys.stdout.write('\r%.1f%%: Looked up %d symbols (%d collisions, '
543 '%d disambiguations where %.1f%% succeeded)' 543 '%d disambiguations where %.1f%% succeeded)'
544 '- %.1f lookups/s.' % 544 ' - %.1f lookups/s.' %
545 (progress_percent, progress.count, progress.collisions, 545 (progress_percent, progress.count, progress.collisions,
546 progress.disambiguations, disambiguation_percent, speed)) 546 progress.disambiguations, disambiguation_percent, speed))
547 547
548 # In case disambiguation was disabled, we remove the source path (which upon 548 # In case disambiguation was disabled, we remove the source path (which upon
549 # being set signals the symbolizer to enable disambiguation) 549 # being set signals the symbolizer to enable disambiguation)
550 if not disambiguate: 550 if not disambiguate:
551 src_path = None 551 src_path = None
552 symbolizer = elf_symbolizer.ELFSymbolizer(library, addr2line_binary, 552 symbolizer = elf_symbolizer.ELFSymbolizer(library, addr2line_binary,
553 map_address_symbol, 553 map_address_symbol,
554 max_concurrent_jobs=jobs, 554 max_concurrent_jobs=jobs,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 line_number = symbol.source_line 611 line_number = symbol.source_line
612 out.write('%s\t%s:%d\n' % (line, path, line_number)) 612 out.write('%s\t%s:%d\n' % (line, path, line_number))
613 continue 613 continue
614 614
615 out.write('%s\n' % line) 615 out.write('%s\n' % line)
616 616
617 print('%d symbols in the results.' % len(address_symbol)) 617 print('%d symbols in the results.' % len(address_symbol))
618 618
619 619
620 def RunNm(binary, nm_binary): 620 def RunNm(binary, nm_binary):
621 print('Starting nm')
622 cmd = [nm_binary, '-C', '--print-size', '--size-sort', '--reverse-sort', 621 cmd = [nm_binary, '-C', '--print-size', '--size-sort', '--reverse-sort',
623 binary] 622 binary]
624 nm_process = subprocess.Popen(cmd, 623 nm_process = subprocess.Popen(cmd,
625 stdout=subprocess.PIPE, 624 stdout=subprocess.PIPE,
626 stderr=subprocess.PIPE) 625 stderr=subprocess.PIPE)
627 (process_output, err_output) = nm_process.communicate() 626 (process_output, err_output) = nm_process.communicate()
628 627
629 if nm_process.returncode != 0: 628 if nm_process.returncode != 0:
630 if err_output: 629 if err_output:
631 raise Exception, err_output 630 raise Exception, err_output
632 else: 631 else:
633 raise Exception, process_output 632 raise Exception, process_output
634 633
635 print('Finished nm')
636 return process_output 634 return process_output
637 635
638 636
639 def GetNmSymbols(nm_infile, outfile, library, jobs, verbose, 637 def GetNmSymbols(nm_infile, outfile, library, jobs, verbose,
640 addr2line_binary, nm_binary, disambiguate, src_path): 638 addr2line_binary, nm_binary, disambiguate, src_path):
641 if nm_infile is None: 639 if nm_infile is None:
642 if outfile is None: 640 if outfile is None:
643 outfile = tempfile.NamedTemporaryFile(delete=False).name 641 outfile = tempfile.NamedTemporaryFile(delete=False).name
644 642
645 if verbose: 643 if verbose:
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 shutil.copy(os.path.join(d3_src, 'LICENSE'), d3_out) 922 shutil.copy(os.path.join(d3_src, 'LICENSE'), d3_out)
925 shutil.copy(os.path.join(d3_src, 'd3.js'), d3_out) 923 shutil.copy(os.path.join(d3_src, 'd3.js'), d3_out)
926 shutil.copy(os.path.join(template_src, 'index.html'), opts.destdir) 924 shutil.copy(os.path.join(template_src, 'index.html'), opts.destdir)
927 shutil.copy(os.path.join(template_src, 'D3SymbolTreeMap.js'), opts.destdir) 925 shutil.copy(os.path.join(template_src, 'D3SymbolTreeMap.js'), opts.destdir)
928 926
929 print 'Report saved to ' + opts.destdir + '/index.html' 927 print 'Report saved to ' + opts.destdir + '/index.html'
930 928
931 929
932 if __name__ == '__main__': 930 if __name__ == '__main__':
933 sys.exit(main()) 931 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/pylib/symbols/elf_symbolizer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698