# Copyright (c) 2013 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.
"""
Make sure PGO is working properly. """
import TestGyp
import os import sys
if sys.platform == 'win32':
test = TestGyp.TestGyp(formats=['msvs', 'ninja'])
def IsPGOAvailable(): """Returns true if the Visual Studio available here supports PGO."""
test.build('pgo.gyp', 'gen_linker_option', chdir=CHDIR)
tmpfile = test.read(test.built_file_path('linker_options.txt', chdir=CHDIR)) return any(line.find('PGOPTIMIZE') for line in tmpfile)
# When PGO is available, try building binaries with PGO. if IsPGOAvailable():
pgd_path = test.built_file_path('test_pgo.pgd', chdir=CHDIR)
# Test if 'PGInstrument' generates PGD (Profile-Guided Database) file. if os.path.exists(pgd_path):
test.unlink(pgd_path)
test.must_not_exist(pgd_path)
test.build('pgo.gyp', 'test_pgo_instrument', chdir=CHDIR)
test.must_exist(pgd_path)
# Test if 'PGOptimize' works well
test.build('pgo.gyp', 'test_pgo_optimize', chdir=CHDIR)
test.must_contain_any_line(test.stdout(), ['profiled functions'])
# Test if 'PGUpdate' works well
test.build('pgo.gyp', 'test_pgo_update', chdir=CHDIR) # With 'PGUpdate', linker should not complain that sources are changed after # the previous training run.
test.touch(test.workpath('linker-flags/inline_test_main.cc'))
test.unlink(test.built_file_path('test_pgo_update.exe', chdir=CHDIR))
test.build('pgo.gyp', 'test_pgo_update', chdir=CHDIR)
test.must_contain_any_line(test.stdout(), ['profiled functions'])
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.