gamecreator Posted November 29, 2011 Share Posted November 29, 2011 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. Quote Link to comment Share on other sites More sharing options...
Pixel Perfect Posted November 29, 2011 Share Posted November 29, 2011 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. Quote 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 More sharing options...
gamecreator Posted November 30, 2011 Author Share Posted November 30, 2011 Fair enough. Would this be better tested by decreasing the frame rate by putting a lot of triangles on the screen? Quote Link to comment Share on other sites More sharing options...
Pixel Perfect Posted November 30, 2011 Share Posted November 30, 2011 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. Quote 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 More sharing options...
gamecreator Posted December 1, 2011 Author Share Posted December 1, 2011 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? Quote Link to comment Share on other sites More sharing options...
Roland Posted January 3, 2012 Share Posted January 3, 2012 This might be a bit off-topic, but what does AppTime actually return. Its said the current application time and nothing more. Is that in milliseconds and whats the resolution (is it msec with resoltuon 15 msec)? It does not seem to be the application time either as it the would start will 0. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
DaDonik Posted January 3, 2012 Share Posted January 3, 2012 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). Quote (Win7 64bit) && (i7 3770K @ 3,5ghz) && (16gb DDR3 @ 1600mhz) && (Geforce660TI) Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted January 3, 2012 Share Posted January 3, 2012 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. Quote 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 More sharing options...
Roland Posted January 3, 2012 Share Posted January 3, 2012 Yes it does. And it loops at some number but I can't remember what that number is. Now how strange isn't that Made a quick test and it seems to increment in 64 msec steps. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
Josh Posted January 5, 2012 Share Posted January 5, 2012 AppTime returns the time at the last UpdateTime() call. This way the time value stays the same for your entire loop, until the next time update. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Roland Posted January 5, 2012 Share Posted January 5, 2012 Thanks for that clarification Josh. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
gamecreator Posted January 7, 2012 Author Share Posted January 7, 2012 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(); Quote Link to comment Share on other sites More sharing options...
DaDonik Posted January 7, 2012 Share Posted January 7, 2012 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()) Quote (Win7 64bit) && (i7 3770K @ 3,5ghz) && (16gb DDR3 @ 1600mhz) && (Geforce660TI) Link to comment Share on other sites More sharing options...
Recommended Posts
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.