fguihen Posted April 19, 2005 Posted April 19, 2005 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; } Quote
Administrators PlausiblyDamp Posted April 20, 2005 Administrators Posted April 20, 2005 Where is Person.DiscountableTime declared and what do it's methods do? As a simple test if you subtract processingStart from processingFinish does the resultant TimeSpan exhibit the same problem or does it reflect a change in time? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
fguihen Posted April 20, 2005 Author Posted April 20, 2005 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.