| OLD | NEW |
| 1 # Copyright 2008 the V8 project authors. All rights reserved. | 1 # Copyright 2008 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 import csv, splaytree, sys | 28 import csv, splaytree, sys |
| 29 from operator import itemgetter | 29 from operator import itemgetter |
| 30 | 30 import getopt, os |
| 31 | 31 |
| 32 class CodeEntry(object): | 32 class CodeEntry(object): |
| 33 | 33 |
| 34 def __init__(self, start_addr, name): | 34 def __init__(self, start_addr, name): |
| 35 self.start_addr = start_addr | 35 self.start_addr = start_addr |
| 36 self.tick_count = 0 | 36 self.tick_count = 0 |
| 37 self.name = name | 37 self.name = name |
| 38 self.stacks = {} | 38 self.stacks = {} |
| 39 | 39 |
| 40 def Tick(self, pc, stack): | 40 def Tick(self, pc, stack): |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 total_stacks += count | 361 total_stacks += count |
| 362 all_stacks_items = all_stacks.items(); | 362 all_stacks_items = all_stacks.items(); |
| 363 all_stacks_items.sort(key = itemgetter(1), reverse=True) | 363 all_stacks_items.sort(key = itemgetter(1), reverse=True) |
| 364 for stack, count in all_stacks_items: | 364 for stack, count in all_stacks_items: |
| 365 total_percentage = count * 100.0 / total_stacks | 365 total_percentage = count * 100.0 / total_stacks |
| 366 print(' %(total)5.1f%% %(call_path)s' % { | 366 print(' %(total)5.1f%% %(call_path)s' % { |
| 367 'total' : total_percentage, | 367 'total' : total_percentage, |
| 368 'call_path' : stack[0] + ' <- ' + stack[1] | 368 'call_path' : stack[0] + ' <- ' + stack[1] |
| 369 }) | 369 }) |
| 370 | 370 |
| 371 |
| 372 class CmdLineProcessor(object): |
| 373 |
| 374 def __init__(self): |
| 375 # default values |
| 376 self.state = None |
| 377 self.ignore_unknown = False |
| 378 self.log_file = None |
| 379 |
| 380 def ProcessArguments(self): |
| 381 try: |
| 382 opts, args = getopt.getopt(sys.argv[1:], "jgco", ["js", "gc", "compiler",
"other", "ignore-unknown"]) |
| 383 except getopt.GetoptError: |
| 384 self.PrintUsageAndExit() |
| 385 for key, value in opts: |
| 386 if key in ("-j", "--js"): |
| 387 self.state = 0 |
| 388 if key in ("-g", "--gc"): |
| 389 self.state = 1 |
| 390 if key in ("-c", "--compiler"): |
| 391 self.state = 2 |
| 392 if key in ("-o", "--other"): |
| 393 self.state = 3 |
| 394 if key in ("--ignore-unknown"): |
| 395 self.ignore_unknown = True |
| 396 self.ProcessRequiredArgs(args) |
| 397 |
| 398 def ProcessRequiredArgs(self, args): |
| 399 return |
| 400 |
| 401 def GetRequiredArgsNames(self): |
| 402 return |
| 403 |
| 404 def PrintUsageAndExit(self): |
| 405 print('Usage: %(script_name)s --{js,gc,compiler,other} %(req_opts)s' % { |
| 406 'script_name': os.path.basename(sys.argv[0]), |
| 407 'req_opts': self.GetRequiredArgsNames() |
| 408 }) |
| 409 sys.exit(2) |
| 410 |
| 411 def RunLogfileProcessing(self, tick_processor): |
| 412 tick_processor.ProcessLogfile(self.log_file, self.state, self.ignore_unknown
) |
| 413 |
| 414 |
| 371 if __name__ == '__main__': | 415 if __name__ == '__main__': |
| 372 sys.exit('You probably want to run windows-tick-processor.py or linux-tick-pro
cessor.py.') | 416 sys.exit('You probably want to run windows-tick-processor.py or linux-tick-pro
cessor.py.') |
| OLD | NEW |