How to find performance bottleneck with profiler widget?

here is a small script. It filters troublemakers. If you know its name you can use rightclick-find functionality to get its location:

findBottleNeck.gh (10.4 KB)

Code:

var activeObjects = GrasshopperDocument.ActiveObjects(); // get all active objects

var results = new Dictionary<string, double>();
for (int i = 0; i < activeObjects.Count; i++) // for each active object...
{
  IGH_ActiveObject ao = activeObjects[i] as IGH_ActiveObject;
  results.Add(string.Format("{0} {1}", i, ao.NickName), ao.ProcessorTime.Milliseconds); // ...store its time and name...
}

foreach (KeyValuePair<string, double> result in results.OrderBy(v => v.Value)) // ...and sort the collection...
{
  Print("{0}\n   {1} ms", result.Key, result.Value); // ...to get the winner
}
4 Likes