This article has been dead for over three months
You
public class FPSMonitor
{
public float Value {get; private set;}
public TimeSpan Sample {get; set;}
private Stopwatch sw;
private int Frames;
public FPSMonitor(Game Game) : base(Game)
{
this.Sample = TimeSpan.FromSeconds(1);
}
public void Initialize()
{
this.Value = 0;
this.Frames = 0;
this.sw = Stopwatch.StartNew();
}
public void Update(GameTime gameTime)
{
if (sw.Elapsed > Sample)
{
this.Value = (float)Frames / sw.Elapsed.TotalSeconds;
this.sw.Reset();
this.sw.Start();
this.Frames = 0;
}
}
public void Draw(GameTime gameTime)
{
this.Frames++;
}
}