Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

i have a method, and i take a time span at the beginning and the same at the end, and take them away, and i should be able to see how long a method takes to do its stuff, but in the miliseconds and ticks both come up as zero at the end. why is this? heres the code.

 


	public void DrawToScreen(Graphics h)
	{

		this.GetStartTime();
		this.processingStart = System.DateTime.Now;
		pen.Color = Color.Black;
		System.Drawing.Font f = new System.Drawing.Font("Arial",8);
		
		h.FillEllipse(new SolidBrush(Color.HotPink),(float)position.Xval,(float)position.Yval,diameter,diameter);
		Vector v = new Vector(this.position.Xval,this.position.Yval);
		v = this.position.Displace(60,8);
		h.DrawString(this.idNum.ToString(),f,new SolidBrush(Color.Black),(float)v.Xval,(float)v.Yval);
		if(this.ShowLines == true)
		{
			h.DrawLine(this.pen,(float)this.LeftSight.Xval,(float)this.LeftSight.Yval,(float)LeftSightEnd.Xval,(float)LeftSightEnd.Yval);
			h.DrawLine(this.pen,(float)this.RightSight.Xval,(float)this.RightSight.Yval,(float)RightSightEnd.Xval,(float)RightSightEnd.Yval);
			h.DrawLine(this.pen,(float)this.RightSight.Xval,(float)this.RightSight.Yval,(float)this.LeftSight.Xval,(float)this.LeftSight.Yval);
			h.DrawLine(this.pen,(float)this.center.Xval,(float)center.Yval,(float)FarSight.Xval,(float)FarSight.Yval);
			
			
	
			h.FillEllipse(new SolidBrush(Color.Red),(float)center.Xval,(float)center.Yval,4,4);
			
		}
		//just have thrown in variables to see contents of second, milisecond and tick 
		//parts of the timespan before and after 
		this.UpdatePos();
		this.processingFinish = System.DateTime.Now;
		int secs = Person.DiscountableTime.Seconds;
		float milli = Person.DiscountableTime.Milliseconds;
		long ticks = Person.DiscountableTime.Ticks;
		Person.DiscountableTime = DiscountableTime.Add((processingFinish.Subtract(processingStart)));
		int secs1 = Person.DiscountableTime.Seconds;
		float milli1 = Person.DiscountableTime.Milliseconds;
		long ticks1 = Person.DiscountableTime.Ticks;
	}

Posted
Where is Person.DiscountableTime declared and what do it's methods do?

 

 

discountable time is a global time span variable that stores the total processing time of each bot and takes it away, so that bot 12 will not have the extra time spent processing bot1 -> bot 11 added to its time, making it inacurate

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...