aboutsummaryrefslogtreecommitdiff
path: root/fdo_scripts/divide_and_merge_profiles.py
diff options
context:
space:
mode:
authorLuis Lozano <llozano@chromium.org>2015-12-15 13:49:30 -0800
committerLuis Lozano <llozano@chromium.org>2015-12-16 17:36:06 +0000
commitf2a3ef46f75d2196a93d3ed27f4d1fcf22b54fbe (patch)
tree185d243c7eed7c7a0db6f0e640746cadc1479ea9 /fdo_scripts/divide_and_merge_profiles.py
parent2a66f70fef907c1cb15229cb58e5129cb620ac98 (diff)
downloadtoolchain-utils-f2a3ef46f75d2196a93d3ed27f4d1fcf22b54fbe.tar.gz
Run pyformat on all the toolchain-utils files.
This gets rid of a lot of lint issues. Ran by doing this: for f in *.py; do echo -n "$f " ; if [ -x $f ]; then pyformat -i --remove_trailing_comma --yapf --force_quote_type=double $f ; else pyformat -i --remove_shebang --remove_trailing_comma --yapf --force_quote_type=double $f ; fi ; done BUG=chromium:567921 TEST=Ran simple crosperf run. Change-Id: I59778835fdaa5f706d2e1765924389f9e97433d1 Reviewed-on: https://chrome-internal-review.googlesource.com/242031 Reviewed-by: Luis Lozano <llozano@chromium.org> Commit-Queue: Luis Lozano <llozano@chromium.org> Tested-by: Luis Lozano <llozano@chromium.org> Reviewed-by: Yunlian Jiang <yunlian@google.com>
Diffstat (limited to 'fdo_scripts/divide_and_merge_profiles.py')
-rwxr-xr-xfdo_scripts/divide_and_merge_profiles.py77
1 files changed, 36 insertions, 41 deletions
diff --git a/fdo_scripts/divide_and_merge_profiles.py b/fdo_scripts/divide_and_merge_profiles.py
index e750a626..390ad54a 100755
--- a/fdo_scripts/divide_and_merge_profiles.py
+++ b/fdo_scripts/divide_and_merge_profiles.py
@@ -1,7 +1,6 @@
#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
-
"""Script to divide and merge profiles."""
import copy
@@ -20,6 +19,7 @@ from utils import logger
class ProfileMerger:
+
def __init__(self, inputs, output, chunk_size, merge_program, multipliers):
self._inputs = inputs
self._output = output
@@ -31,13 +31,14 @@ class ProfileMerger:
def _GetFilesSetForInputDir(self, input_dir):
output_file = tempfile.mktemp()
- command = "find %s -name '*.gcda' -o -name '*.imports' > %s" % (input_dir, output_file)
+ command = "find %s -name '*.gcda' -o -name '*.imports' > %s" % (input_dir,
+ output_file)
self._ce.RunCommand(command)
- files = open(output_file, "r").read()
+ files = open(output_file, 'r').read()
files_set = set([])
for f in files.splitlines():
- stripped_file = f.replace(input_dir, "", 1)
- stripped_file = stripped_file.lstrip("/")
+ stripped_file = f.replace(input_dir, '', 1)
+ stripped_file = stripped_file.lstrip('/')
files_set.add(stripped_file)
return files_set
@@ -60,9 +61,9 @@ class ProfileMerger:
src_file = os.path.join(input_dir, f)
dst_file = os.path.join(output_dir, f)
if not os.path.isdir(os.path.dirname(dst_file)):
- command = "mkdir -p %s" % os.path.dirname(dst_file)
+ command = 'mkdir -p %s' % os.path.dirname(dst_file)
self._ce.RunCommand(command)
- command = "cp %s %s" % (src_file, dst_file)
+ command = 'cp %s %s' % (src_file, dst_file)
self._ce.RunCommand(command)
def _DoChunkMerge(self, current_files):
@@ -72,17 +73,14 @@ class ProfileMerger:
temp_dirs.append(temp_dir)
self._CopyFilesTree(i, current_files, temp_dir)
# Now do the merge.
- command = ("%s --inputs=%s --output=%s" %
- (self._merge_program,
- ",".join(temp_dirs),
- self._output))
+ command = ('%s --inputs=%s --output=%s' %
+ (self._merge_program, ','.join(temp_dirs), self._output))
if self._multipliers:
- command = ("%s --multipliers=%s" %
- (command, self._multipliers))
+ command = ('%s --multipliers=%s' % (command, self._multipliers))
ret = self._ce.RunCommand(command)
- assert ret == 0, "%s command failed!" % command
+ assert ret == 0, '%s command failed!' % command
for temp_dir in temp_dirs:
- command = "rm -rf %s" % temp_dir
+ command = 'rm -rf %s' % temp_dir
self._ce.RunCommand(command)
def DoMerge(self):
@@ -97,49 +95,46 @@ class ProfileMerger:
def Main(argv):
"""The main function."""
# Common initializations
-### command_executer.InitCommandExecuter(True)
+ ### command_executer.InitCommandExecuter(True)
command_executer.InitCommandExecuter()
l = logger.GetLogger()
ce = command_executer.GetCommandExecuter()
parser = optparse.OptionParser()
- parser.add_option("--inputs",
- dest="inputs",
- help="Comma-separated input profile directories to merge.")
- parser.add_option("--output",
- dest="output",
- help="Output profile directory.")
- parser.add_option("--chunk_size",
- dest="chunk_size",
- default="50",
- help="Chunk size to divide up the profiles into.")
- parser.add_option("--merge_program",
- dest="merge_program",
- default="/home/xur/bin/profile_merge_v15.par",
- help="Merge program to use to do the actual merge.")
- parser.add_option("--multipliers",
- dest="multipliers",
- help="multipliers to use when merging. (optional)")
+ parser.add_option('--inputs',
+ dest='inputs',
+ help='Comma-separated input profile directories to merge.')
+ parser.add_option('--output', dest='output', help='Output profile directory.')
+ parser.add_option('--chunk_size',
+ dest='chunk_size',
+ default='50',
+ help='Chunk size to divide up the profiles into.')
+ parser.add_option('--merge_program',
+ dest='merge_program',
+ default='/home/xur/bin/profile_merge_v15.par',
+ help='Merge program to use to do the actual merge.')
+ parser.add_option('--multipliers',
+ dest='multipliers',
+ help='multipliers to use when merging. (optional)')
options, _ = parser.parse_args(argv)
- if not all([options.inputs,
- options.output,]):
- l.LogError("Must supply --inputs and --output")
+ if not all([options.inputs, options.output]):
+ l.LogError('Must supply --inputs and --output')
return 1
try:
- pm = ProfileMerger(options.inputs.split(","), options.output,
- int(options.chunk_size), options.merge_program,
- options.multipliers)
+ pm = ProfileMerger(
+ options.inputs.split(','), options.output, int(options.chunk_size),
+ options.merge_program, options.multipliers)
pm.DoMerge()
retval = 0
except:
retval = 1
finally:
- print "My work is done..."
+ print 'My work is done...'
return retval
-if __name__ == "__main__":
+if __name__ == '__main__':
retval = Main(sys.argv)
sys.exit(retval)