Mercurial > public > mercurial-scm > hg
comparison mercurial/statprof.py @ 48913:f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
pycompat.iteritems() just calls .items().
This commit applies a regular expression search and replace to convert
simple instances of pycompat.iteritems() with .items(). There are still
a handful of calls to pycompat.iteritems() remaining. But these all have
more complicated expressions that I wasn't comfortable performing an
automated replace on. In addition, some simple replacements were withheld
because they broke pytype. These will be handled by their own changesets.
Differential Revision: https://phab.mercurial-scm.org/D12318
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 03 Mar 2022 18:28:30 -0800 |
parents | 6000f5b25c9b |
children | 2cce2fa5bcf7 |
comparison
equal
deleted
inserted
replaced
48912:a0674e916fb6 | 48913:f254fc73d956 |
---|---|
571 for stat in stats: | 571 for stat in stats: |
572 grouped[stat.site.filename() + b":" + stat.site.function].append(stat) | 572 grouped[stat.site.filename() + b":" + stat.site.function].append(stat) |
573 | 573 |
574 # compute sums for each function | 574 # compute sums for each function |
575 functiondata = [] | 575 functiondata = [] |
576 for fname, sitestats in pycompat.iteritems(grouped): | 576 for fname, sitestats in grouped.items(): |
577 total_cum_sec = 0 | 577 total_cum_sec = 0 |
578 total_self_sec = 0 | 578 total_self_sec = 0 |
579 total_percent = 0 | 579 total_percent = 0 |
580 for stat in sitestats: | 580 for stat in sitestats: |
581 total_cum_sec += stat.totalseconds() | 581 total_cum_sec += stat.totalseconds() |
650 if site in children: | 650 if site in children: |
651 children[site] = children[site] + 1 | 651 children[site] = children[site] + 1 |
652 else: | 652 else: |
653 children[site] = 1 | 653 children[site] = 1 |
654 | 654 |
655 parents = [(parent, count) for parent, count in pycompat.iteritems(parents)] | 655 parents = [(parent, count) for parent, count in parents.items()] |
656 parents.sort(reverse=True, key=lambda x: x[1]) | 656 parents.sort(reverse=True, key=lambda x: x[1]) |
657 for parent, count in parents: | 657 for parent, count in parents: |
658 fp.write( | 658 fp.write( |
659 b'%6.2f%% %s:%s line %s: %s\n' | 659 b'%6.2f%% %s:%s line %s: %s\n' |
660 % ( | 660 % ( |
694 total_self_sec, | 694 total_self_sec, |
695 total_self_percent, | 695 total_self_percent, |
696 ) | 696 ) |
697 ) | 697 ) |
698 | 698 |
699 children = [(child, count) for child, count in pycompat.iteritems(children)] | 699 children = [(child, count) for child, count in children.items()] |
700 children.sort(reverse=True, key=lambda x: x[1]) | 700 children.sort(reverse=True, key=lambda x: x[1]) |
701 for child, count in children: | 701 for child, count in children: |
702 fp.write( | 702 fp.write( |
703 b' %6.2f%% line %s: %s\n' | 703 b' %6.2f%% line %s: %s\n' |
704 % ( | 704 % ( |
825 lines[line] = 1 | 825 lines[line] = 1 |
826 | 826 |
827 fd, path = pycompat.mkstemp() | 827 fd, path = pycompat.mkstemp() |
828 | 828 |
829 with open(path, b"w+") as file: | 829 with open(path, b"w+") as file: |
830 for line, count in pycompat.iteritems(lines): | 830 for line, count in lines.items(): |
831 file.write(b"%s %d\n" % (line, count)) | 831 file.write(b"%s %d\n" % (line, count)) |
832 | 832 |
833 if outputfile is None: | 833 if outputfile is None: |
834 outputfile = b'~/flamegraph.svg' | 834 outputfile = b'~/flamegraph.svg' |
835 | 835 |