Thread: [GD-General] remove unused functions
Brought to you by:
vexxed72
From: Corrinne Y. <cor...@sp...> - 2003-05-19 18:57:54
|
The game engine and game code base has gotten very very big. And it is about time to clean things up and improve its structure and documentation. One thing I would like to do to it is to start removing un-used functions. I tried to use MSDev to remove un-referenced functions as a start but didn't find any. It turns out quite a few of the "un-used" functions are "referenced" (and thus can't be that easily automatically determined) but I know from how the game and engine code is supposed to run that they won't ever be called. They are not exactly unreachable code either, so doing the unreachable code thing also doesn't work. I truly "dread" :D the idea to have to manually step through all the code and manually cull out every single un-used function by hand (it is a lot of code to wade through!). I wonder what tools exist inside of MSDev (or simple easy to use small external tools) that can help me in my highly un fun task of cleaning up my code base, specifically in the task of removing "un-used" functions. Thank you for your experience in this task, and your suggestions. |
From: Stefan B. <ste...@te...> - 2003-05-19 20:35:19
|
> I truly "dread" :D the idea to have to manually step through all the > code and manually cull out every single un-used function by hand (it = is > a lot of code to wade through!). I wonder what tools exist inside of > MSDev (or simple easy to use small external tools) that can help me in > my highly un fun task of cleaning up my code base, specifically in the > task of removing "un-used" functions. There are coverage analysis tools that you could use to do this. = Normally these tools are used in automated testing, to verify that all code paths = are exercised by the test cases. We have some Rational PurifyPlus licenses = and as part of their package they bundle Quantify and PureCoverage. I'm sure there are lots of other packages available but I have no idea what's the best solution.=20 Anyway, just Google for "code coverage analysis" or something like = that and you should get plenty of hits. Cheers, Stef! :) -- Stefan Boberg, R&D Manager - Team17 Software Ltd. bo...@te... |
From: Neil S. <ne...@r0...> - 2003-05-19 21:21:51
|
> One thing I would like to do to it is to start removing un-used > functions. I tried to use MSDev to remove un-referenced functions as a > start but didn't find any. It turns out quite a few of the "un-used" > functions are "referenced" (and thus can't be that easily automatically > determined) but I know from how the game and engine code is supposed to > run that they won't ever be called. > > They are not exactly unreachable code either, so doing the unreachable > code thing also doesn't work. What about using a code coverage tool, like Compuware's DevPartner or something similar? They are really designed to show what code is (and isn't) covered by unit tests, but they might be able to work with an entire run of your code. If not, you could create some unit tests for each of your components, such as rendering, AI, etc., and then run them through such a tool. - Neil. |
From: Corrinne Y. <cor...@sp...> - 2003-05-20 00:01:39
|
Thank you for all these suggestions. Quite a few of them sound do-able. Using a formal analysis tool would had been good if it were done from the beginning, but at this point I am probably stuck with several of the global "#define" search and replace and text dump suggestions, as I am trying to do this with as little new code writing, and as little "learning how to use a new tool" as possible. I may consider looking at code analysis tools when I start a new project (or using the existing engine to start a new project, or let other companies or teams use the existing engine with a new project) to see if it is a lot of work and effort (or high learning curve). I wish I had looked more into "big code project type tools" earlier on; kept convincing myself my project probably would be "small" and it does turn into one of those "software project management size" type of code base; it got even bigger than source code projects for when I worked for other companies and teams. Engines and games must have gotten highly complex in the last year or so and had increased greatly in function complexity. Games and engines after this one probably would become so huge that "formal software documentation and structuring" would become almost a necessity for the next round. (Days of winging it un-documented appear to be diminishing. :) ) Again, thank you for all the pointers. They have all been very helpful. |
From: Jamie F. <ja...@qu...> - 2003-05-20 10:52:47
|
have you tried a profiler? take a profiler which will instrument the functions for you, then use the counts to find which functions are never really used? Jamie -----Original Message----- From: gam...@li... [mailto:gam...@li...]On Behalf Of Corrinne Yu Sent: 19 May 2003 19:58 To: gam...@li... Subject: [GD-General] remove unused functions The game engine and game code base has gotten very very big. And it is about time to clean things up and improve its structure and documentation. One thing I would like to do to it is to start removing un-used functions. I tried to use MSDev to remove un-referenced functions as a start but didn't find any. It turns out quite a few of the "un-used" functions are "referenced" (and thus can't be that easily automatically determined) but I know from how the game and engine code is supposed to run that they won't ever be called. They are not exactly unreachable code either, so doing the unreachable code thing also doesn't work. I truly "dread" :D the idea to have to manually step through all the code and manually cull out every single un-used function by hand (it is a lot of code to wade through!). I wonder what tools exist inside of MSDev (or simple easy to use small external tools) that can help me in my highly un fun task of cleaning up my code base, specifically in the task of removing "un-used" functions. Thank you for your experience in this task, and your suggestions. ------------------------------------------------------- This SF.net email is sponsored by: ObjectStore. If flattening out C++ or Java code to make your application fit in a relational database is painful, don't do it! Check out ObjectStore. Now part of Progress Software. http://www.objectstore.net/sourceforge _______________________________________________ Gamedevlists-general mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-general Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=557 |
From: Laurent G. <lg...@pa...> - 2003-05-20 23:58:39
|
If you use MSVC 7, had you try to set Property|C/C++|Optimization|Global Optimizations to Yes ? Look at LTCG in the documentation... Even if it's much more an optimization option, it's actually remove all unused function (even in our case)... > -----Message d'origine----- > De : gam...@li... > [mailto:gam...@li...]De la part de > Corrinne Yu > Envoye : lundi 19 mai 2003 20:58 > A : gam...@li... > Objet : [GD-General] remove unused functions > > > The game engine and game code base has gotten very very big. And it is > about time to clean things up and improve its structure and > documentation. > > One thing I would like to do to it is to start removing un-used > functions. I tried to use MSDev to remove un-referenced functions as a > start but didn't find any. It turns out quite a few of the "un-used" > functions are "referenced" (and thus can't be that easily > automatically > determined) but I know from how the game and engine code is > supposed to > run that they won't ever be called. > > They are not exactly unreachable code either, so doing the unreachable > code thing also doesn't work. > > I truly "dread" :D the idea to have to manually step through all the > code and manually cull out every single un-used function by > hand (it is > a lot of code to wade through!). I wonder what tools exist inside of > MSDev (or simple easy to use small external tools) that can help me in > my highly un fun task of cleaning up my code base, specifically in the > task of removing "un-used" functions. > > Thank you for your experience in this task, and your suggestions. > > > > ------------------------------------------------------- > This SF.net email is sponsored by: ObjectStore. > If flattening out C++ or Java code to make your application fit in a > relational database is painful, don't do it! Check out ObjectStore. > Now part of Progress Software. http://www.objectstore.net/sourceforge > _______________________________________________ > Gamedevlists-general mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-general > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=557 > |