diff --git a/utils/opt-viewer/opt-viewer.py b/utils/opt-viewer/opt-viewer.py index bc30618c854..c936597475c 100755 --- a/utils/opt-viewer/opt-viewer.py +++ b/utils/opt-viewer/opt-viewer.py @@ -5,9 +5,16 @@ from __future__ import print_function desc = '''Generate HTML output to visualize optimization records from the YAML files generated with -fsave-optimization-record and -fdiagnostics-show-hotness. -The tools requires PyYAML and Pygments Python packages.''' +The tools requires PyYAML and Pygments Python packages. + +For faster parsing, you may want to use libYAML with PyYAML.''' import yaml +# Try to use the C parser. +try: + from yaml import CLoader as Loader +except ImportError: + from yaml import Loader import argparse import os.path import re @@ -34,6 +41,9 @@ def demangle(name): class Remark(yaml.YAMLObject): max_hotness = 0 + # Work-around for http://pyyaml.org/ticket/154. + yaml_loader = Loader + @classmethod def should_display_hotness(cls): # If max_hotness is 0 at the end, we assume hotness information is @@ -273,7 +283,7 @@ file_remarks = dict() for input_file in args.yaml_files: f = open(input_file) - docs = yaml.load_all(f) + docs = yaml.load_all(f, Loader=Loader) for remark in docs: # Avoid remarks withoug debug location or if they are duplicated if not hasattr(remark, 'DebugLoc') or remark.key in all_remarks: