Infrastructure to support calibration runs of TimeSCons tests, which
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 10 Dec 2009 03:42:30 +0000 (03:42 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 10 Dec 2009 03:42:30 +0000 (03:42 +0000)
only run a full build and report back the values of any variables
affecting the configuration, and the elapsed time of the full build.

git-svn-id: http://scons.tigris.org/svn/scons/trunk@4541 fdb21ef1-2011-0410-befe-b5e4ea1792b1

QMTest/TestSCons.py
timings/CPPPATH/TimeSCons-run.py
timings/JTimer/TimeSCons-run.py
timings/hundred/TimeSCons-run.py

index 929567d94efeae098c3d7733683a1a83a65769cd..002baaae3bcde7912eef0a71883b601bfca0905f 100644 (file)
@@ -997,8 +997,23 @@ class TimeSCons(TestSCons):
         directory containing the executing script to the temporary
         working directory.
         """
+        self.variables = kw.get('variables')
+        if self.variables is not None:
+            for variable, value in self.variables.items():
+                value = os.environ.get(variable, value)
+                try:
+                    value = int(value)
+                except ValueError:
+                    try:
+                        value = float(value)
+                    except ValueError:
+                        pass
+                self.variables[variable] = value
+            del kw['variables']
+
         if not kw.has_key('verbose'):
             kw['verbose'] = True
+
         # TODO(1.5)
         #TestSCons.__init__(self, *args, **kw)
         apply(TestSCons.__init__, (self,)+args, kw)
@@ -1028,13 +1043,24 @@ class TimeSCons(TestSCons):
         The elapsed time to execute each build is printed after
         it has finished.
         """
-        # TODO(1.5)
-        #self.help(*args, **kw)
-        #self.full(*args, **kw)
-        #self.null(*args, **kw)
-        apply(self.help, args, kw)
-        apply(self.full, args, kw)
-        apply(self.null, args, kw)
+        if not kw.has_key('options') and self.variables:
+            options = []
+            for variable, value in self.variables.items():
+                options.append('%s=%s' % (variable, value))
+            kw['options'] = ' '.join(options)
+        calibrate = os.environ.get('TIMESCONS_CALIBRATE')
+        if calibrate in (None, '0'):
+            # TODO(1.5)
+            #self.help(*args, **kw)
+            #self.full(*args, **kw)
+            #self.null(*args, **kw)
+            apply(self.help, args, kw)
+            apply(self.full, args, kw)
+            apply(self.null, args, kw)
+        else:
+            # TODO(1.5)
+            #self.calibration(*args, **kw)
+            apply(self.calibration, args, kw)
 
     def trace(self, graph, name, value, units, sort=None):
         fmt = "TRACE: graph=%s name=%s value=%s units=%s"
@@ -1081,6 +1107,20 @@ class TimeSCons(TestSCons):
         sys.stdout.write(self.stdout())
         self.report_traces('full', self.stdout())
 
+    def calibration(self, *args, **kw):
+        """
+        Runs a full build of SCons, but only reports calibration
+        information (the variable(s) that were set for this configuration,
+        and the elapsed time to run.
+        """
+        # TODO(1.5)
+        #self.run(*args, **kw)
+        apply(self.run, args, kw)
+        if self.variables:
+            for variable, value in self.variables.items():
+                sys.stdout.write('VARIABLE: %s=%s\n' % (variable, value))
+        sys.stdout.write('ELAPSED: %s\n' % self.elapsed_time())
+
     def null(self, *args, **kw):
         """
         Runs an up-to-date null build of SCons.
index d88042e678b9884cccbf307d87a26de7a3c8696f..dcee7c5c15c45a32311be39bd0cec422913f671d 100644 (file)
@@ -32,13 +32,11 @@ file #includes the .h file to be found in the last directory in the list.
 
 import TestSCons
 
-test = TestSCons.TimeSCons()
+test = TestSCons.TimeSCons(variables={'DIR_COUNT':5000})
 
-dir_count = 5000
-
-for d in xrange(dir_count):
+for d in xrange(test.variables['DIR_COUNT']):
     test.subdir('inc_%04d' % d)
 
-test.main(options='DIR_COUNT=%s' % dir_count)
+test.main()
 
 test.pass_test()
index 36b016f1b7a7e533242ca5aa17fc5e1392a61737..05ffbfb929420c34d5ca5a8d7f8d496f86a9e797 100644 (file)
@@ -38,6 +38,8 @@ to the Taskmaster so it could be smarter about not re-evaluating Nodes.
 
 import TestSCons
 
-target_count = 500
+test = TestSCons.TimeSCons(variables={'TARGET_COUNT':500})
 
-TestSCons.TimeSCons().main(options='TARGET_COUNT=%d' % target_count)
+test.main()
+
+test.pass_test()
index d21db8a56b5299ca6ad3069eefae18b2a03567b3..915c131948f28ec7d0c2f590390a459b36e32662 100644 (file)
@@ -33,13 +33,11 @@ equivalent of "echo contents > $TARGET".
 
 import TestSCons
 
-test = TestSCons.TimeSCons()
+test = TestSCons.TimeSCons(variables={'TARGET_COUNT':500})
 
-target_count = 500
-
-for t in xrange(target_count):
+for t in xrange(test.variables['TARGET_COUNT']):
     open('source_%04d' % t, 'wb' ).write('contents\n')
 
-test.main(options='TARGET_COUNT=%s' % target_count)
+test.main()
 
 test.pass_test()