Author: peterw
Date: 2006-07-07 01:08:29 -0400 (Fri, 07 Jul 2006)
New Revision: 62340

Added:
   
branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/GraphStateProfiler.cs
Modified:
   branches/peterw/mbuild-compiled/Monkeywrench.dll.sources
   branches/peterw/mbuild-compiled/Monkeywrench/ChangeLog
   branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/ProjectManager.cs
   branches/peterw/mbuild-compiled/mbuild/ChangeLog
   branches/peterw/mbuild-compiled/mbuild/mbuild.cs
Log:
2006-07-07  Peter Williams  <[EMAIL PROTECTED]>

        * Monkeywrench/GraphStateProfiler.cs: New class, passes through calls
        to an IGraphState while keeping track of how many times each interface
        method is called.

        * Monkeywrench/ProjectManager.cs (ProfileStateUsage): New static field;
        use a GraphStateProfiler if set and print the results on disposal.

mbuild:

2006-07-07  Peter Williams  <[EMAIL PROTECTED]>

        * mbuild.cs (profile_graph): New command-line option that triggers
        use of the GraphStateProfiler class.



Modified: branches/peterw/mbuild-compiled/Monkeywrench/ChangeLog
===================================================================
--- branches/peterw/mbuild-compiled/Monkeywrench/ChangeLog      2006-07-07 
04:15:57 UTC (rev 62339)
+++ branches/peterw/mbuild-compiled/Monkeywrench/ChangeLog      2006-07-07 
05:08:29 UTC (rev 62340)
@@ -1,3 +1,12 @@
+2006-07-07  Peter Williams  <[EMAIL PROTECTED]>
+
+       * Monkeywrench/GraphStateProfiler.cs: New class, passes through calls
+       to an IGraphState while keeping track of how many times each interface
+       method is called.
+
+       * Monkeywrench/ProjectManager.cs (ProfileStateUsage): New static field;
+       use a GraphStateProfiler if set and print the results on disposal.
+
 2006-07-06  Peter Williams  <[EMAIL PROTECTED]>
 
        * Monkeywrench/FileStateTable.cs: Clean this up -- we were serializing

Added: 
branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/GraphStateProfiler.cs
===================================================================
--- 
branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/GraphStateProfiler.cs 
    2006-07-07 04:15:57 UTC (rev 62339)
+++ 
branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/GraphStateProfiler.cs 
    2006-07-07 05:08:29 UTC (rev 62340)
@@ -0,0 +1,161 @@
+using System;
+using System.Text;
+using System.Collections;
+
+using Mono.Build;
+
+namespace Monkeywrench.Compiler {
+
+    public class GraphStateProfiler : IGraphState {
+
+       IGraphState inner;
+
+       public GraphStateProfiler (IGraphState inner)
+       {
+           if (inner == null)
+               throw new ArgumentNullException ("inner");
+
+           this.inner = inner;
+       }
+
+       int n_GetProviderBasis = 0;
+       public string GetProviderBasis (short id)
+       {
+           n_GetProviderBasis++;
+           return inner.GetProviderBasis (id);
+       }
+
+       int n_GetProviderDeclarationLoc = 0;
+       public string GetProviderDeclarationLoc (short id)
+       {
+           n_GetProviderDeclarationLoc++;
+           return inner.GetProviderDeclarationLoc (id);
+       }
+
+       int n_GetProviderId = 0;
+       public short GetProviderId (string basis)
+       {
+           n_GetProviderId++;
+           return inner.GetProviderId (basis);
+       }
+
+       int n_NumProviders = 0;
+       public short NumProviders {
+           get {
+               n_NumProviders++;
+               return inner.NumProviders;
+           }
+       }
+
+       int n_GetProviderTargetBound = 0;
+       public int GetProviderTargetBound (short id)
+       {
+           n_GetProviderTargetBound++;
+           return inner.GetProviderTargetBound (id);
+       }
+
+       int n_GetTargetName = 0;
+       public string GetTargetName (int tid)
+       {
+           n_GetTargetName++;
+           return inner.GetTargetName (tid);
+       }
+
+       int n_GetTargetId = 0;
+       public int GetTargetId (string target)
+       {
+           n_GetTargetId++;
+           return inner.GetTargetId (target);
+       }
+
+       int n_GetTargetRule = 0;
+       public Rule GetTargetRule (int tid)
+       {
+           n_GetTargetRule++;
+           return inner.GetTargetRule (tid);
+       }
+
+       int n_ApplyTargetDependencies = 0;
+       public bool ApplyTargetDependencies (int tid, ArgCollector ac, 
IWarningLogger logger)
+       {
+           n_ApplyTargetDependencies++;
+           return inner.ApplyTargetDependencies (tid, ac, logger);
+       }
+
+       int n_TargetHasTag = 0;
+       public bool TargetHasTag (int tid, int tag)
+       {
+           n_TargetHasTag++;
+           return inner.TargetHasTag (tid, tag);
+       }
+
+       int n_GetTargetTag = 0;
+       public object GetTargetTag (int tid, int tag)
+       {
+           n_GetTargetTag++;
+           return inner.GetTargetTag (tid, tag);
+       }
+
+       int n_GetTagId = 0;
+       public int GetTagId (string tag)
+       {
+           n_GetTagId++;
+           return inner.GetTagId (tag);
+       }
+
+       int n_GetTagName = 0;
+       public string GetTagName (int tag)
+       {
+           n_GetTagName++;
+           return inner.GetTagName (tag);
+       }
+
+       int n_GetDependentFiles = 0;
+       public IEnumerable GetDependentFiles ()
+       {
+           n_GetDependentFiles++;
+           return inner.GetDependentFiles ();
+       }
+
+       int n_GetDependentBundles = 0;
+       public IEnumerable GetDependentBundles ()
+       {
+           n_GetDependentBundles++;
+           return inner.GetDependentBundles ();
+       }
+
+       int n_GetProjectInfo = 0;
+       public ProjectInfo GetProjectInfo ()
+       {
+           n_GetProjectInfo++;
+           return inner.GetProjectInfo ();
+       }
+
+       // And finally ...
+
+       public override string ToString ()
+       {
+           StringBuilder sb = new StringBuilder ();
+           string nl = Environment.NewLine;
+
+           sb.AppendFormat ("GetProviderBasis: {0}{1}", n_GetProviderBasis, 
nl);
+           sb.AppendFormat ("GetProviderDeclarationLoc: {0}{1}", 
n_GetProviderDeclarationLoc, nl);
+           sb.AppendFormat ("GetProviderId: {0}{1}", n_GetProviderId, nl);
+           sb.AppendFormat ("NumProviders: {0}{1}", n_NumProviders, nl);
+           sb.AppendFormat ("GetProviderTargetBound: {0}{1}", 
n_GetProviderTargetBound, nl);
+           sb.AppendFormat ("GetTargetName: {0}{1}", n_GetTargetName, nl);
+           sb.AppendFormat ("GetTargetId: {0}{1}", n_GetTargetId, nl);
+           sb.AppendFormat ("GetTargetRule: {0}{1}", n_GetTargetRule, nl);
+           sb.AppendFormat ("ApplyTargetDependencies: {0}{1}", 
n_ApplyTargetDependencies, nl);
+           sb.AppendFormat ("TargetHasTag: {0}{1}", n_TargetHasTag, nl);
+           sb.AppendFormat ("GetTargetTag: {0}{1}", n_GetTargetTag, nl);
+           sb.AppendFormat ("GetTagId: {0}{1}", n_GetTagId, nl);
+           sb.AppendFormat ("GetTagName: {0}{1}", n_GetTagName, nl);
+           sb.AppendFormat ("GetDependentFiles: {0}{1}", n_GetDependentFiles, 
nl);
+           sb.AppendFormat ("GetDependentBundles: {0}{1}", 
n_GetDependentBundles, nl);
+           sb.AppendFormat ("GetProjectInfo: {0}{1}", n_GetProjectInfo, nl);
+
+           return sb.ToString ();
+       }
+    }
+}

Modified: 
branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/ProjectManager.cs
===================================================================
--- branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/ProjectManager.cs 
2006-07-07 04:15:57 UTC (rev 62339)
+++ branches/peterw/mbuild-compiled/Monkeywrench/Monkeywrench/ProjectManager.cs 
2006-07-07 05:08:29 UTC (rev 62340)
@@ -53,6 +53,8 @@
            return false;
        }
 
+       public static bool ProfileStateUsage = false;
+
        public bool LoadRest (IWarningLogger uilog) 
        {
            if ((log = ActionLog.Load (ss, uilog)) == null)
@@ -61,6 +63,9 @@
            if ((graph = GetGraph ()) == null)
                return true;
 
+           if (ProfileStateUsage)
+               graph = new GraphStateProfiler (graph);
+
            proj = new WrenchProject (ss, graph, log);
            return false;
        }
@@ -140,6 +145,15 @@
                log = null;
            }
 
+           if (ProfileStateUsage) {
+               Console.Error.WriteLine ("GRAPH STATE USAGE PROFILE:");
+               Console.Error.WriteLine ("{0}", graph);
+           }
+
+           graph = null;
+           ss = null;
+           bm = null;
+
            disposed = true;
        }
     }

Modified: branches/peterw/mbuild-compiled/Monkeywrench.dll.sources
===================================================================
--- branches/peterw/mbuild-compiled/Monkeywrench.dll.sources    2006-07-07 
04:15:57 UTC (rev 62339)
+++ branches/peterw/mbuild-compiled/Monkeywrench.dll.sources    2006-07-07 
05:08:29 UTC (rev 62340)
@@ -1,6 +1,7 @@
 Monkeywrench/Monkeywrench/ActionLog.cs
 Monkeywrench/Monkeywrench/BuildServices.cs
 Monkeywrench/Monkeywrench/FileStateTable.cs
+Monkeywrench/Monkeywrench/GraphStateProfiler.cs
 Monkeywrench/Monkeywrench/IProviderPersistence.cs
 Monkeywrench/Monkeywrench/MakeDictionaryRule.cs
 Monkeywrench/Monkeywrench/OperationFunc.cs

Modified: branches/peterw/mbuild-compiled/mbuild/ChangeLog
===================================================================
--- branches/peterw/mbuild-compiled/mbuild/ChangeLog    2006-07-07 04:15:57 UTC 
(rev 62339)
+++ branches/peterw/mbuild-compiled/mbuild/ChangeLog    2006-07-07 05:08:29 UTC 
(rev 62340)
@@ -1,3 +1,8 @@
+2006-07-07  Peter Williams  <[EMAIL PROTECTED]>
+
+       * mbuild.cs (profile_graph): New command-line option that triggers
+       use of the GraphStateProfiler class.
+
 2006-07-06  Peter Williams  <[EMAIL PROTECTED]>
 
        * mbuild.cs: Track LoggingData -> ActionLog rename.

Modified: branches/peterw/mbuild-compiled/mbuild/mbuild.cs
===================================================================
--- branches/peterw/mbuild-compiled/mbuild/mbuild.cs    2006-07-07 04:15:57 UTC 
(rev 62339)
+++ branches/peterw/mbuild-compiled/mbuild/mbuild.cs    2006-07-07 05:08:29 UTC 
(rev 62340)
@@ -91,6 +91,9 @@
        [Option("Debug the logging data", ' ', "debug-logs")]
        public bool debug_logs = false;
 
+       [Option("Profile the graph access", ' ', "profile-graph")]
+       public bool profile_graph = false;
+
        OperationScope scope = OperationScope.HereAndBelow;
        OperationFunc func;
        int numbuilt, numskipped, numcleaned, numdisted, numinstalled;
@@ -792,6 +795,7 @@
 
                BuildfileParser.DebugParser = debug_parser;
                ActionLog.DebugEvents = debug_logs;
+               ProjectManager.ProfileStateUsage = profile_graph;
                Monkeywrench.Compiler.XmlGraphSerializer.DebugOutput = true; // 
FIXME
                ProjectManager pm = null;
                string here = "/";

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to