is this framerate script okay?

Just trying to check the framerate when running on iOS device. My script is below, but it causes an overflow error in the debug log. Also, when run in unity this script displays 59-60fps but the Unity stat counter shows 75fps. Why is that?

function Update() {
// Time.time is time in seconds since start of app, frameCount is total frames since start of app
var framerate = (Time.frameCount / Time.time);
// Convert to integer
var intFramerate : int = Mathf.Round(framerate);

guiText.text = "fps: " + intFramerate;

}

Just use this.

Using Time.frameCount would at best give you the average framerate from the start of the game.

You probably want to use Time.smoothDeltaTime or Time.deltaTime, which will give you the number of seconds since the last frame. Smooth delta time gives you the number of seconds since the last frame smoothed over the last few frames, giving you a more reasonable estimate for the fps.

var fps = 1/Time.smoothDeltaTime;