diff options
author | Chris Bieneman <beanz@apple.com> | 2016-03-22 16:27:35 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2016-03-22 16:27:35 +0000 |
commit | d4f094bb2b3c4d8ae66c825b32b2a68e5f6eeec4 (patch) | |
tree | 7f4d206436af62ff908d95c35d4dbdbc88b05e9a | |
parent | 25fb4177fb80631abe0dcecb6c6e14de4ebc695a (diff) | |
download | bcm5719-llvm-d4f094bb2b3c4d8ae66c825b32b2a68e5f6eeec4.tar.gz bcm5719-llvm-d4f094bb2b3c4d8ae66c825b32b2a68e5f6eeec4.zip |
[Perf-training] Cleanup based on feedback from Sean Silvas
Sean provided feedback based on r257934 on cfe-commits. This change addresses that feedback.
llvm-svn: 264063
-rw-r--r-- | clang/utils/perf-training/perf-helper.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/clang/utils/perf-training/perf-helper.py b/clang/utils/perf-training/perf-helper.py index 3fd1c0bb7c9..5d1c03332d6 100644 --- a/clang/utils/perf-training/perf-helper.py +++ b/clang/utils/perf-training/perf-helper.py @@ -99,9 +99,11 @@ def dtrace(args): if sys.platform == "darwin": dtrace_args.append('-xmangled') - f = open("%d.dtrace" % os.getpid(), "w") start_time = time.time() - subprocess.check_call(dtrace_args, stdout=f, stderr=subprocess.PIPE) + + with open("%d.dtrace" % os.getpid(), "w") as f: + subprocess.check_call(dtrace_args, stdout=f, stderr=subprocess.PIPE) + elapsed = time.time() - start_time print("... data collection took %.4fs" % elapsed) @@ -111,7 +113,7 @@ def get_cc1_command_for_args(cmd, env): # Find the cc1 command used by the compiler. To do this we execute the # compiler with '-###' to figure out what it wants to do. cmd = cmd + ['-###'] - cc_output = check_output(cmd, stderr=subprocess.STDOUT, env=env).strip() + cc_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, env=env).strip() cc_commands = [] for ln in cc_output.split('\n'): # Filter out known garbage. @@ -246,13 +248,6 @@ def parse_dtrace_symbol_file(path, all_symbols, all_symbols_set, for s in possible_symbols: yield (current_timestamp, s) -def check_output(*popen_args, **popen_kwargs): - p = subprocess.Popen(stdout=subprocess.PIPE, *popen_args, **popen_kwargs) - stdout,stderr = p.communicate() - if p.wait() != 0: - raise RuntimeError("process failed") - return stdout - def uniq(list): seen = set() for item in list: @@ -346,7 +341,7 @@ def genOrderFile(args): # If the user gave us a binary, get all the symbols in the binary by # snarfing 'nm' output. if opts.binary_path is not None: - output = check_output(['nm', '-P', opts.binary_path]) + output = subprocess.check_output(['nm', '-P', opts.binary_path]) lines = output.split("\n") all_symbols = [ln.split(' ',1)[0] for ln in lines |