forked from OSchip/llvm-project
[lit] Avoid calling realpath() for every printed message
I did some profiling of lit while trying to optimize the libc++ test startup for remote hosts and it turns out that there is a realpath() call for every message printed and this shows up in the profile. The inspect.getframeinfo() function calls realpath() internally and moreover we don't need most of the other information returned from it. This patch uses inspect.getsourcefile() and os.path.abspath() to remove ../ from the path instead. Not resolving symlinks reduces the startup time for running a single test with lit by about 50ms for me. Reviewed By: ldionne, yln Differential Revision: https://reviews.llvm.org/D89186
This commit is contained in:
parent
482e6f0041
commit
9a6ae91128
|
@ -165,11 +165,10 @@ class LitConfig(object):
|
|||
f = inspect.currentframe()
|
||||
# Step out of _write_message, and then out of wrapper.
|
||||
f = f.f_back.f_back
|
||||
file,line,_,_,_ = inspect.getframeinfo(f)
|
||||
location = '%s:%d' % (file, line)
|
||||
|
||||
sys.stderr.write('%s: %s: %s: %s\n' % (self.progname, location,
|
||||
kind, message))
|
||||
file = os.path.abspath(inspect.getsourcefile(f))
|
||||
line = inspect.getlineno(f)
|
||||
sys.stderr.write('%s: %s:%d: %s: %s\n' % (self.progname, file, line,
|
||||
kind, message))
|
||||
|
||||
def note(self, message):
|
||||
if not self.quiet:
|
||||
|
|
Loading…
Reference in New Issue