Jump to content

AppSpeed


gamecreator
 Share

Recommended Posts

I was testing my program to see how it would behave on slower computers, by adding various Sleep amounts in my code. To my surprise, the program didn't act as I expected. So, I decided to write a simple test program to see why this was the case. Here is the relevant part:

 

float x=0.0;
double t1, t2;

t1=t2=timeGetTime();

while(!KeyHit(KEY_ESCAPE))
{
Sleep(1);

x+=0.01*AppSpeed();

if(x>5)
{
	t2=timeGetTime();
	x=-10000.0;
}

UpdateFramework();
RenderFramework();

DrawText(0,20,"x: %f",x);
DrawText(0,40,"AppSpeed: %f",AppSpeed());
DrawText(0,60,"time: %f",t2-t1);

Flip(0);
}

 

I noticed that as I increased the Sleep amount, the time it took x to go from 0 to 5 took longer and longer.

 

Sleep(amount): time

1: 8185ms

10: 8295ms

50: 8757ms

100: 9322ms

 

Is this difference expected? I get that we're talking milliseconds here but this could be the difference between making a jump and missing a cliff, especially if the fps drops in certain scenes.

Link to comment
Share on other sites

I don't know how accurate the AppSpeed() function is but certainly the sleep function is not that accurate and is dependent on the tick resolution of the system its being run on. It tend to be less accurate on low values (< 10ms) and even when it completes, the thread is not guaranteed to restart immediately.

 

You might want to do a comparison using a high resolution timer that simply loops rather than sleeps the thread.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

That might be more representative of the type of situation you would really face but there would normally be a non rendering cost associated with running game logic/AI too (unless it was a very simple game) which is better simulated by loops. A combination of both might be better. But you could try increasing polygon rendering initially, that should start to bring the frame rate down fairly quickly from an initial high value.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

I wrote the code to only include loaded models (not Sleep). This is what I got:

 

models - fps - time

0 - 1080 - 8169

25 - 189 - 8216

50 - 100 - 8265

75 - 68 - 8326

100 - 51 - 8376

150 - 34 - 8476

200 - 26 - 8560

300 - 17 - 8756

500 - 10 - 9182

 

If you do the conversion between these results and the results in the first post, you'll find they're actually pretty close and linear (though I did my bit of rounding so this is hardly exact). For example, the 10 frames per second with a heavy model load brought the result time to 9,182ms whereas above, with a 100ms Sleep (also 10fps), the time was 9,322.

 

Does this mean that AppSpeed can't be relied upon to give you the same results on two different computers?

Link to comment
Share on other sites

  • 1 month later...

If you really want to know how your game will behave on a slower PC, it's not enough to slow down you CPU. You should also remove your GPU and put in a really bad one.

 

Does this mean that AppSpeed can't be relied upon to give you the same results on two different computers?

AppSpeed returns 1.0 if your game runs at 60fps, 2.0 at 30fps and 0.5 at 120 fps. I tested this on 3 different PC's by just increasing/decreasing the amount of cubes i render. It was not a precise measurement, but at around 30fps AppSpeed returns ~2.0.

 

It does not seem to be the application time either as it the would start will 0.

I could be wrong, but i think that AppTime() just returns the system time (time in milliseconds since startup).

(Win7 64bit) && (i7 3770K @ 3,5ghz) && (16gb DDR3 @ 1600mhz) && (Geforce660TI)

Link to comment
Share on other sites

I could be wrong, but i think that AppTime() just returns the system time (time in milliseconds since startup).

 

Yes it does. And it loops at some number but I can't remember what that number is.

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

AppSpeed returns 1.0 if your game runs at 60fps, 2.0 at 30fps and 0.5 at 120 fps. I tested this on 3 different PC's by just increasing/decreasing the amount of cubes i render. It was not a precise measurement, but at around 30fps AppSpeed returns ~2.0.

Then any idea what's wrong with my code? Shouldn't this make x increase at a constant speed on all computers?

 

x+=0.01*AppSpeed();

Link to comment
Share on other sites

When using the curve function i do:

fMove = Curve ((float)(KeyDown (KEY_W) - KeyDown (KEY_S)), fMove, 5.0f / AppSpeed());

For movements i do:

float fMove = fMove * ((1.0f / 1000.0f) * AppSpeed());

After that fMove is measured in meter/second. To make it easier for me i made myself a macro:

#define M_S     (0.016666f * AppSpeed())

(Win7 64bit) && (i7 3770K @ 3,5ghz) && (16gb DDR3 @ 1600mhz) && (Geforce660TI)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...