Print the dependency tree
after each top-level target is built. This prints out only derived files.
+.TP
+.RI --debug=time
+Prints various time profiling information: the time spent
+executing each build command, the total build time, the total time spent
+executing build commands, the total time spent executing SConstruct and
+SConscript files, and the total time spent executing SCons itself.
+
.TP
-e, --environment-overrides
Variables from the execution environment override construction
- Fix .sconsign signature storage so that output files of one build
can be safely used as input files to another build.
+ - Added a --debug=time option to print SCons execution times.
+
From Zed Shaw:
- Add an Append() method to Environments, to append values to
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import time
+start_time = time.time()
+
import getopt
import os
import os.path
else:
try:
self.targets[0].prepare()
+ if print_time:
+ start_time = time.time()
self.targets[0].build()
+ if print_time:
+ finish_time = time.time()
+ global command_time
+ command_time = command_time+finish_time-start_time
+ print "Command execution time: %f seconds"%(finish_time-start_time)
+
except BuildError, e:
sys.stderr.write("scons: *** [%s] %s\n" % (e.node, e.errstr))
if e.errstr == 'Exception':
help_option = None
print_tree = 0
print_dtree = 0
+print_time = 0
+sconscript_time = 0
+command_time = 0
climb_up = 0
target_top = None
exit_status = 0 # exit status, assume success by default
profiling = 0
max_drift = None
+
# utility functions
def get_all_children(node): return node.all_children(None)
def opt_debug(opt, arg):
global print_tree
global print_dtree
+ global print_time
if arg == "pdb":
args = [ sys.executable, "pdb.py" ] + \
filter(lambda x: x != "--debug=pdb", sys.argv)
print_tree = 1
elif arg == "dtree":
print_dtree = 1
+ elif arg == "time":
+ print_time = 1
else:
sys.stderr.write("Warning: %s is not a valid debug type\n"
% arg)
sys.path = include_dirs + sys.path
+ start_time = time.time()
for script in scripts:
SCons.Script.SConscript.SConscript(script)
+ global sconscript_time
+ sconscript_time = time.time() - start_time
SCons.Node.FS.default_fs.chdir(SCons.Node.FS.default_fs.Top)
except:
_scons_other_errors()
+ if print_time:
+ total_time = time.time()-start_time
+ scons_time = total_time-sconscript_time-command_time
+ print "Total build time: %f seconds"%total_time
+ print "Total SConscript file execution time: %f seconds"%sconscript_time
+ print "Total SCons execution time: %f seconds"%scons_time
+ print "Total command execution time: %f seconds"%command_time
+
sys.exit(exit_status)
import TestSCons
import sys
import string
+import re
+import time
test = TestSCons.TestSCons()
test.fail_test(string.find(test.stdout(), "(Pdb)") == -1)
test.fail_test(string.find(test.stdout(), "scons") == -1)
+test.write('foo.c', r"""
+#include "foo.h"
+
+int main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("f1.c\n");
+ exit (0);
+}
+""")
+
+test.write('bar.c', """
+#include "bar.h"
+
+""")
+
+############################
+# test --debug=time
+
+def num(match, line):
+ return float(re.match(match, line).group(1))
+
+start_time = time.time()
+test.run(program=sys.executable, arguments='-c pass')
+overhead = time.time() - start_time
+
+start_time = time.time()
+test.run(arguments = "--debug=time .")
+expected_total_time = time.time() - start_time - overhead
+line = string.split(test.stdout(), '\n')
+
+expected_command_time = num(r'Command execution time: (\d+\.\d+) seconds', line[1])
+expected_command_time = expected_command_time + num(r'Command execution time: (\d+\.\d+) seconds', line[3])
+expected_command_time = expected_command_time + num(r'Command execution time: (\d+\.\d+) seconds', line[5])
+expected_command_time = expected_command_time + num(r'Command execution time: (\d+\.\d+) seconds', line[6])
+
+total_time = num(r'Total build time: (\d+\.\d+) seconds', line[7])
+sconscript_time = num(r'Total SConscript file execution time: (\d+\.\d+) seconds', line[8])
+scons_time = num(r'Total SCons execution time: (\d+\.\d+) seconds', line[9])
+command_time = num(r'Total command execution time: (\d+\.\d+) seconds', line[10])
+
+def check(expected, actual, tolerance):
+ return abs((expected-actual)/actual) <= tolerance
+
+assert check(expected_command_time, command_time, 0.01)
+assert check(total_time, sconscript_time+scons_time+command_time, 0.01)
+assert check(total_time, expected_total_time, 0.1)
+
test.pass_test()