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
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: