OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 |
| 3 # Copyright (c) 2013 Google Inc. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
| 7 from optparse import OptionParser |
| 8 import glob |
| 9 import os |
| 10 import subprocess |
| 11 |
| 12 parser = OptionParser() |
| 13 parser.add_option('--exe', dest='exe') |
| 14 parser.add_option('--vcbindir', dest='vcbindir') |
| 15 parser.add_option('--pgd', dest='pgd') |
| 16 (options, args) = parser.parse_args() |
| 17 |
| 18 # Instrumented binaries fail to run unless the Visual C++'s bin dir is included |
| 19 # in the PATH environment variable. |
| 20 os.environ['PATH'] = os.environ['PATH'] + os.pathsep + options.vcbindir |
| 21 |
| 22 # Run Instrumented binary. The profile will be recorded into *.pgc file. |
| 23 subprocess.call([options.exe]) |
| 24 |
| 25 # Merge *.pgc files into a *.pgd (Profile-Guided Database) file. |
| 26 subprocess.call(['pgomgr', '/merge', options.pgd]) |
| 27 |
| 28 # *.pgc files are no longer necessary. Clear all of them. |
| 29 pgd_file = os.path.abspath(options.pgd) |
| 30 pgd_dir = os.path.dirname(pgd_file) |
| 31 (pgd_basename, _) = os.path.splitext(os.path.basename(pgd_file)) |
| 32 pgc_filepattern = os.path.join(pgd_dir, '%s!*.pgc' % pgd_basename) |
| 33 pgc_files= glob.glob(pgc_filepattern) |
| 34 for pgc_file in pgc_files: |
| 35 os.unlink(pgc_file) |
OLD | NEW |