Search code examples
windows-phone-7xnawindows-phone-7-emulator

Low FPS on WIndows 7 Phone Emulator


I'm writing a game for a Windows 7 Phone using XNA 4.0, Visual Studio 2010 Pro and the built in Windows 7 Phone Emulator. I downloaded a couple of GameState samples but I get very low FPS, even with no real graphics work going on. It stutters between 30, 15, then 10, just generally slow.

My computer's not a screamer but I have a Core I5 2.4ghz laptop and 4gb of RAM, so I gotta think it can keep up with whatever hardware is on a phone.

Any ideas? Is this normal? Maybe my way of measuring FPS is wrong (I use fps=1/gametime.elapsedtime.totalseconds)?


Solution

  • In order to calculate your FPS, you can use this code:

    //time since last FPS update in seconds
        float deltaFPSTime = 0;
    
        protected override void Update()
        {
            // The time since Update was called last
            float elapsed = (float)ElapsedTime.TotalSeconds;
    
            float fps = 1 / elapsed;
            deltaFPSTime += elapsed;
            if (deltaFPSTime>1)
            {
    
                Window.Title = "I am running at  <" + fps.ToString()+"> FPS";
                deltaFPSTime-=1;
            }
            // Let the GameComponents update
            UpdateComponents();
        }
    

    Check for more samples of FPS counters there.

    With this code in place, test if you're still getting weird results.