Axiom.Core.Root.CalculateEventTime C# (CSharp) Method

CalculateEventTime() private method

Internal method for calculating the average time between recently fired events.
private CalculateEventTime ( long time, FrameEventType type ) : float
time long The current time in milliseconds.
type FrameEventType The type event to calculate.
return float
		private float CalculateEventTime( long time, FrameEventType type )
		{
			float result = 0;

			if ( type == FrameEventType.Start)
			{
				result = (float)( time - this.lastStartTime ) / 1000;

				// update the last start time before the render targets are rendered
				this.lastStartTime = time;
			}
			if ( type == FrameEventType.Queued )
			{
				result = (float)( time - this.lastQueuedTime ) / 1000;
				// update the last queued time before the render targets are rendered
				this.lastQueuedTime = time;
			}
			else if ( type == FrameEventType.End )
			{
				// increment frameCount
				this.frameCount++;

				// collect performance stats
				if ( ( time - this.lastCalculationTime ) > this.secondsBetweenFPSAverages * 1000f )
				{
					// Is It Time To Update Our Calculations?
					// Calculate New Framerate
					this.currentFPS = (float)this.frameCount / (float)( time - this.lastCalculationTime ) * 1000f;

					// calculate the average framerate
					if ( this.averageFPS == 0 )
					{
						this.averageFPS = this.currentFPS;
					}
					else
					{
						this.averageFPS = ( this.averageFPS + this.currentFPS ) / 2.0f;
					}

					// Is The New Framerate A New Low?
					if ( this.currentFPS < this.lowestFPS || (int)this.lowestFPS == 0 )
					{
						// Set It To The New Low
						this.lowestFPS = this.currentFPS;
					}

					// Is The New Framerate A New High?
					if ( this.currentFPS > this.highestFPS )
					{
						// Set It To The New High
						this.highestFPS = this.currentFPS;
					}

					// Update Our Last Frame Time To Now
					this.lastCalculationTime = time;

					// Reset Our Frame Count
					this.frameCount = 0;
				}

				result = (float)( time - this.lastEndTime ) / 1000;

				this.lastEndTime = time;
			}

			return result;
		}