diff --git a/clcache.py b/clcache.py index cd299de8..15c7ee04 100644 --- a/clcache.py +++ b/clcache.py @@ -58,6 +58,9 @@ CompilerArtifacts = namedtuple('CompilerArtifacts', ['objectFilePath', 'stdout', 'stderr']) +# Enable cProfile +CLCACHE_PROFILE = 'CLCACHE_PROFILE' in os.environ + def printBinary(stream, rawData): stream.buffer.write(rawData) @@ -1515,4 +1518,8 @@ def processNoDirect(cache, objectFile, compiler, cmdLine): return returnCode, compilerStdout, compilerStderr if __name__ == '__main__': - sys.exit(main()) + if CLCACHE_PROFILE: + import cProfile + cProfile.run('main()') + else: + sys.exit(main())