Commits

dirkbaechle  committed d6428e5

- added pympler output to Main.py

  • Participants
  • Parent commits b362ac5
  • Branches pympler_mem_analysis

Comments (0)

Files changed (1)

File src/engine/SCons/Script/Main.py

         for label, stats in zip(self.labels, self.stats):
             self.outfp.write(fmt % (label, stats))
 
-memory_stats = MemStats()
+from pympler.classtracker import ClassTracker
+
+class MemPymplerStats(Stats):
+    def __init__(self):
+        Stats.__init__(self)
+        classes = [SCons.Node.Node, SCons.Node.FS.Base, SCons.Node.FS.File,
+                   SCons.Node.FS.Dir, SCons.Executor.Executor,
+                   SCons.Action.CommandAction, 
+                   SCons.Action.CommandGeneratorAction,
+                   SCons.Action.FunctionAction,
+                   SCons.Action.LazyAction,
+                   SCons.Action.ListAction,
+                   SCons.Builder.BuilderBase,
+                   SCons.Builder.CompositeBuilder,
+                   SCons.Environment.Base,
+                   SCons.Environment.BuilderDict,
+                   SCons.Environment.BuilderWrapper,
+                   SCons.Environment.MethodWrapper,
+                   SCons.Environment.OverrideEnvironment,
+                   SCons.Environment.SubstitutionEnvironment,
+                   SCons.Taskmaster.AlwaysTask,
+                   SCons.Taskmaster.OutOfDateTask,
+                   SCons.Taskmaster.Task,
+                   SCons.Taskmaster.Taskmaster]
+        self.tracker = ClassTracker()
+        for c in classes:
+            self.tracker.track_class(c)
+    def do_append(self, label):
+        self.tracker.create_snapshot(label)
+    def do_print(self):
+        stats = self.tracker.stats
+        stats.print_summary()
+        stats.dump_stats('pympler.stats')
+
+memory_stats = MemPymplerStats()
 
 # utility functions
 
     parts.append("__COPYRIGHT__")
     version = ''.join(parts)
 
+    from pympler import tracker
+    memory_tracker = tracker.SummaryTracker()
+    memory_tracker.print_diff()
+
     import SConsOptions
     parser = SConsOptions.Parser(version)
     values = SConsOptions.SConsValues(parser.get_default_values())
         print "Total SCons execution time: %f seconds"%scons_time
         print "Total command execution time: %f seconds"%ct
 
+    memory_tracker.print_diff()
+
     sys.exit(exit_status)
 
 # Local Variables: