Be a Supporter!

tracing frame render time

  • 401 Views
  • 5 Replies
New Topic Respond to this Topic
blakemoso
blakemoso
  • Member since: Apr. 2, 2011
  • Offline.
Forum Stats
Member
Level 05
Game Developer
tracing frame render time 2012-05-18 20:09:30 Reply

Im trying to set up responsive quality controls in my game (so that when it gets laggy the quality automatically steps down for a bit)

I tested the frame rate, and it stays where its supposed to be the whole time, so Im wondering if there's a way to trace the time it takes for flash to render each frame?

(sorry if thats a stupid question, if it is, just ignore it and point me in a better direction!)

Thanks!
(this should be the last question I have to ask for awhile :o)


BBS Signature
caseymacneil
caseymacneil
  • Member since: Nov. 19, 2008
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to tracing frame render time 2012-05-18 21:52:26 Reply

you'll have to wright your own method of getting the fps, this is the one i use.

private var prevtime:int = 0;

		private function update(e:Event):void {
			var time:int
			
			//show text on screen
			
            time = getTimer();
			
			if(delay.expired){
				delay.reset(10);
				fps = 1000 / (time - prevTime); delay.reset(10);
			}
			//
            
			prevTime = getTimer();
			
			update()
		}
caseymacneil
caseymacneil
  • Member since: Nov. 19, 2008
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to tracing frame render time 2012-05-18 22:01:23 Reply

negate the "update()" at the end of my code, something from what i was making and forgot to cut out when i made the post.

egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Supporter
Level 05
Game Developer
Response to tracing frame render time 2012-05-19 16:27:25 Reply

At 5/18/12 08:09 PM, blakemoso wrote: Im trying to set up responsive quality controls in my game (so that when it gets laggy the quality automatically steps down for a bit)

I tested the frame rate, and it stays where its supposed to be the whole time, so Im wondering if there's a way to trace the time it takes for flash to render each frame?

(sorry if thats a stupid question, if it is, just ignore it and point me in a better direction!)

Thanks!
(this should be the last question I have to ask for awhile :o)

you, my good sir, have a brilliant idea. Auto-quality control. I like it. Just make sure to allow a user override


Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature
Khronosis
Khronosis
  • Member since: Mar. 28, 2010
  • Offline.
Forum Stats
Member
Level 17
Programmer
Response to tracing frame render time 2012-05-19 16:56:34 Reply

This thread inspired me to try making a quality adjuster as well.
Here it is:

import flash.utils.getTimer;

var curTime:int = 0;
var prevTime:int = 0;
var diffTime:int = 0;
var fps:int = 0;

private function adjustQuality():void
		{
			prevTime = curTime;
			curTime = getTimer();
			diffTime = curTime - prevTime;
			
			fps = int((1 / diffTime) * 1000);

			if(fps <= (stage.frameRate - 10))
			{
				stage.quality = StageQuality.LOW;
			}
			else if(fps > (stage.frameRate - 10) && fps <= (stage.frameRate - 5))
			{
				stage.quality = StageQuality.MEDIUM;
			}
			else
			{
				stage.quality = StageQuality.HIGH;
			}
		}

I implore you to reconsider.

egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Supporter
Level 05
Game Developer
Response to tracing frame render time 2012-05-19 17:10:38 Reply

At 5/19/12 04:56 PM, Khronosis wrote: This thread inspired me to try making a quality adjuster as well.
Here it is:

import flash.utils.getTimer;

var curTime:int = 0;
var prevTime:int = 0;
var diffTime:int = 0;
var fps:int = 0;

private function adjustQuality():void
{
prevTime = curTime;
curTime = getTimer();
diffTime = curTime - prevTime;

fps = int((1 / diffTime) * 1000);

if(fps <= (stage.frameRate - 10))
{
stage.quality = StageQuality.LOW;
}
else if(fps > (stage.frameRate - 10) && fps <= (stage.frameRate - 5))
{
stage.quality = StageQuality.MEDIUM;
}
else
{
stage.quality = StageQuality.HIGH;
}
}

I see two issues with that code (though I don't actually know AS3. Just AS2)

1.the millisecond the FPS drops to 10, it switches the quality to low. So if a player's fps drops to 2 and then goes back to 30, it's going to confuse the hell out of them because all of a sudden they lost quality for a quarter of a second

2. Once you reduce the quality, the FPS is going to go back up. It's going to constantly switch between "HIGH" and "LOW" and annoy the hell out of the player.


Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature