Can you think of a way to quickly determine which functions never get called?

Previous topic - Next topic

Wampus

Can you think of a way to quickly determine which functions are included in your code but never get called?

I've noticed that the standard codebase I'm using for new games/apps is getting very large, which slows down compiling time. Isn't much of an issue but it would be nice to know what I'm using and what I'm not, especially on slower machines and for 48hr game jams, etc.

Using the profiler and running through all the possible main game/app states its possible to see which functions get called. Very helpful. Can anyone think of a way to quickly determine which aren't used, i.e. aren't listed by the profiler? For example, is there are a way to quickly list all of the functions included in a game or app and then use the information from the profiler to eliminate un-used code?

I'm thinking that my codebase should start off all commented out and then I can un-comment the code as and when its needed. Still, that doesn't help with projects I've already been working on.

kanonet

I guess just looking at the function list for each gbas is not enough. Then you could export a help file for each gbas and then merge them, but that much work too. Only other way that I can think of ATM is writing a simple little program that scans gbas files of a project and outputs all function names that are in them. You could even extend this to eliminate all functions that are created but are have not a single call in the whole project.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Darmakwolf

Well basically what I did was make a new source file for EACH function. 1st compile would take ages, then it'd be 1-2 second compiles after that, because it skips unchanged files. Best I can suggest.

Moru

Is your codebase a single file or do you have it sorted up for different usages?
display.gbas
fonts.gbas
sound.gbas

and so on. That way you can split it up in logical blocks that are easy to add to your new program depending on what you need. Only other options I can think of is to make a scanner to go through your project and see what is used and comment out functions or just make one file and let the compiler take care of the problem with the compile-once, use many-functionality :-)

Wampus

A little proggy to scan all gbas files and list declared functions would be good. Adding the ability to see which functions never get called wouldn't be too difficult either, and commenting them out.

And Darmakwolf, you're right. It is so much faster compiling when skipping unchanged files. My codebase is all one giant gbas file so I'll split it up. Should help.

I'm doing one of those 48hr game jams in November. Its been many months since I've coded for fun. Gotta get back into it. :)

Moru

But aren't those competitions usually supposed to be without using your old codebase?

fuzzy70

Quote from: Moru on 2013-Oct-28
But aren't those competitions usually supposed to be without using your old codebase?

I Think you are allowed to use some old code, for example you may have a particle engine, code to handle input or tileable map scroller etc etc.

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

Wampus

Yeah existing libraries are OK. Generally you are allowed to use old code so long as you say you're going to do so before the theme of the game jam is announced. You also have to make the code available to the other game jammers and link to it prior to the start of the jam, so that everyone can see and use it.

The thing is, these events are often called competitions yet treating them like a competition can be terribly frustrating. I won't do that anymore. Its like running in a race where you all start at different points on the track and other people have brought bikes, cars, even frickin' jet packs. If you're there to push yourself to cross the finish line on your own terms, or for the experience of running and finishing as a group, then its a rewarding experience. I much prefer thinking of game jams like that now.