Reading Profiler Results

I’m not quite understanding how to read the results of the Profiler:

So a method “Pathfinding_NodeAdjuster.CheckSpecificArea()” method is using up 94.7% of the “BehaviorUpdate” overall time, while taking 73.4% of that time on itself (taking ~74ms of actual time) excluding other function calls. What I don’t understand is where this 74ms time is coming from.

Now I realize that if I averaged the time for all 1221 calls of this method, I would probably end up with ~74ms of time spent. But what is that time being spent on? I would have suspected GetComponent() / adding and clearing the List / something like that. But those are listed separately and only combine to get a few ms of time between them. So, where is all the time being spent coming from?

I’ve included the method in question, if you want more info just let me know. Any ideas are appreciated.

	private bool CheckSpecificArea(List<GraphUpdateScene> gusAreaToCheck, GraphNode gn)
	{
		for (int areaCounter = 0; areaCounter < gusAreaToCheck.Count; areaCounter++) //check node location against each area of a certain type
		{
			if(nodeXZValues.x >= gusAreaToCheck[areaCounter].transform.GetComponent<Renderer>().bounds.min.x && nodeXZValues.x <= gusAreaToCheck[areaCounter].transform.GetComponent<Renderer>().bounds.max.x && 
			   nodeXZValues.y >= gusAreaToCheck[areaCounter].transform.GetComponent<Renderer>().bounds.min.z && nodeXZValues.y <= gusAreaToCheck[areaCounter].transform.GetComponent<Renderer>().bounds.max.z)
				//basic bounds test to see if point could possibly be contained within the area before doing more advanced test (remember XY is really XZ).
			{

				gusPointList.Clear(); //prevent stacking.

				for (int i = 0; i < gusAreaToCheck[areaCounter].points.Length; i++) //for each polygon shape's nodes
				{
					gusNodeXZValues.x = gusAreaToCheck[areaCounter].points*.x;*

_ gusNodeXZValues.y = gusAreaToCheck[areaCounter].points*.z;*_

* gusPointList.Add(gusNodeXZValues);*
* }*

* if (PolyContainsPoint.ContainsPoint(gusPointList, nodeXZValues)) //needs GUS objects to use WORLD SPACE!!*
* {*
* gn.Tag = (uint)gusAreaToCheck[areaCounter].areaType; //set node tag value to the value of the GUS containing said point.*

* return true;*
* }*
* else*
* {*
* #if DebugMaster*
* //Debug.Log(“!PolyContainsPoint.ContainsPoint(gusPointList, nodeXZValues), NO match found”);*
* #endif*
* }*
* }*
* else*
* {*
* #if DebugMaster*
* //Debug.Log(“nodeXZValues NOT contained within renderer bounderies of: gusAreaToCheck[” + areaCounter + “], test concluded”);*
* #endif*
* }*
* }*

* return false;*
* }*

Without linking your classes and functions, we can’t really deduce 100% what’s going on. That said, you may want to start referencing things ahead of time, versus getting them every time you want some value. See if this speeds anything up:

private bool CheckSpecificArea(List<GraphUpdateScene> gusAreaToCheck, GraphNode gn)
{
	//check node location against each area of a certain type
	for (int areaCounter = 0; areaCounter < gusAreaToCheck.Count; areaCounter++) 
	{
		// The area we want
		GraphUpdateScene currentGus = gusAreaToCheck[areaCounter];

		// Get the renderer ahead of time
		Bounds gBounds = currentGus.transform.GetComponent<Renderer>().bounds;

		// Create a rect from this
		float xSize = gBounds.max.x - gBounds.min.x;
		float zSize = gBounds.max.z - gBounds.min.z;

		// Construct a Rect using the bounds, since that seems to be what you're checking anyway
		Rect xzBoundingRect = new Rect(gBounds.min.x, gBounds.min.z, xSize, zSize);

		// Get the point we're interested in
		Vector2 point = new Vector2(nodeXZValues.x, nodeXZValues.y);

		if(xzBoundingRect.Contains(point))
		{
			//prevent stacking.
			gusPointList.Clear(); 
			
			//for each polygon shape's nodes
			for (int i = 0; i < currentGus.points.Length; i++) 
			{
				gusNodeXZValues.x = currentGus.points*.x;*

_ gusNodeXZValues.y = currentGus.points*.z;*_

* gusPointList.Add(gusNodeXZValues);*
* }*

* //needs GUS objects to use WORLD SPACE!!*
* if (PolyContainsPoint.ContainsPoint(gusPointList, nodeXZValues))*
* {*
* //set node tag value to the value of the GUS containing said point.*
* gn.Tag = (uint)currentGus.areaType;*

* return true;*
* }*
* }*
* }*
* return false;*