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

Side by Side Diff: tools/gcmole/parallel.py

Issue 931233002: Make gcmole execute in parallel. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Python review Created 5 years, 10 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/gcmole/gcmole.lua ('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
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2015 the V8 project authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """
7 This script calls the first argument for each of the following arguments in
8 parallel. E.g.
9 parallel.py "clang --opt" file1 file2
10 calls
11 clang --opt file1
12 clang --opt file2
13
14 The output (stdout and stderr) is concatenated sequentially in the form:
15 ______________ file1
16 <output of clang --opt file1>
17 ______________ finish <exit code of clang --opt file1> ______________
18 ______________ file2
19 <output of clang --opt file2>
20 ______________ finish <exit code of clang --opt file2> ______________
21 """
22
23 import itertools
24 import multiprocessing
25 import subprocess
26 import sys
27
28 def invoke(cmdline):
29 try:
30 return (subprocess.check_output(
31 cmdline, shell=True, stderr=subprocess.STDOUT), 0)
32 except subprocess.CalledProcessError as e:
33 return (e.output, e.returncode)
34
35 if __name__ == '__main__':
36 assert len(sys.argv) > 2
37 processes = multiprocessing.cpu_count()
38 pool = multiprocessing.Pool(processes=processes)
39 cmdlines = ["%s %s" % (sys.argv[1], filename) for filename in sys.argv[2:]]
40 for filename, result in itertools.izip(
41 sys.argv[2:], pool.imap(invoke, cmdlines)):
42 print "______________ %s" % filename
43 print result[0]
44 print "______________ finish %d ______________" % result[1]
OLDNEW
« no previous file with comments | « tools/gcmole/gcmole.lua ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698