Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Inline VS function call

Author
Message
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 18th Jan 2016 09:42
I have a function for a sprite, in the function a sprite is assigned an image, positioned then drawn. My question is: is inlining this faster than calling a function, any drawbacks of inlining? I use tier 1 at the moment. I call this function a lot, even during screen update. I can divide it up so screen update use it inlined and not speed essentiel stuff will call the function.
13/0
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 18th Jan 2016 13:02
Unless your game has dropped below 60FPS, I wouldn't worry about it.

I used to try and optimise my code so much that I spent hours improving things by a couple of nanoseconds. I finally realised that it only matters if FPS has dropped too low.
I still write efficient code, but I don't worry about function calls. It is more important that the code is maintainable

The biggest problem with inlining is that you write the same piece of code multiple times. This increases the chances of bugs, especially if you update the code later.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 18th Jan 2016 13:35 Edited at: 18th Jan 2016 14:43
Okay, thanks I just do these optimizations to lower system requirements I will use inlining in essential screen update, and function calls anywhere else.

I have another problem. I use "write long" in my old DBPro made map editor to write four bytes integers to a map file, but I cannot read them as integers in AGK2 with "GetMemblockInt" (I load the whole file into memory first, just so that users running my app from a HDD have optimized read as HDD likes reading big chunks of data in one go). If I change this to bytes, I can read them in my AGK2 app, but I do need numbers much, much higher than a bytes 255 :-P Can you point me in any other direction? Like splitting up integers to bytes?

EDIT: I tried this:



But I still get nothing when trying to read back in AGK2 :-( I tried reversing the byte order, no luck :-(

EDIT 2: I fixed it, somehow I went back to writing the integer as a long in DBPro app, I read them back like this:



instead of just:



and that, somehow, fixed my long standing problem with long ints written to file from a DBPro app
13/0
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 29th Jan 2016 20:47
I used to make a sort of rope simulation in DBPro.

When the codes are read directly in the loop, I got 5000 fps

When I transform it into a function, I only got 1000 fps

Login to post a reply

Server time is: 2024-03-29 15:06:20
Your offset time is: 2024-03-29 15:06:20