tools: in performance-log-viewer.py, cache source file lookups

In the performance-log viewer, cache the results of source-file
lookups, to speed up future lookups.
This commit is contained in:
Ell 2018-09-30 05:34:59 -04:00
parent 0f38709259
commit 97498017c0
1 changed files with 23 additions and 15 deletions

View File

@ -82,6 +82,7 @@ editor_command = os.environ.get ("PERFORMANCE_LOG_VIEWER_EDITOR",
editor_command += " &"
def find_file (filename):
def lookup (filename):
filename = re.sub ("[\\\\/]", GLib.DIR_SEPARATOR_S, filename)
if GLib.path_is_absolute (filename):
@ -105,6 +106,13 @@ def find_file (filename):
return None
if filename not in find_file.cache:
find_file.cache[filename] = lookup (filename)
return find_file.cache[filename]
find_file.cache = {}
VariableType = namedtuple ("VariableType",
("parse", "format", "format_numeric"))