Results 1 to 1 of 1
- 03-18-2011, 09:48 PM #1Member
- Join Date
- Mar 2011
- Rep Power
Sharp decrease in program speed after adding small amount of code.
I'm working on a image analysis program for my work that has gotten to be around 2000 lines long. It has been going extremely quickly (fast for this program means completing in around 20 seconds), but there are a couple of blocks of code that I want to add are making it go up to 300% slower! Such an extreme decrease in speed doesn't make any sense to me, so I was hoping to get some ideas. After tinkering around, here are the things I know about what is happening:
1. Adding in a block of code is making EVERY part of the program run slower.
2. It doesn't even matter if this block of code gets run. It just matters that it's getting compiled. If I precede the block with something like "if( true ) return;" then the compiler just ignores the block and the program runs quickly. If I precede the block with "if( [insert some condition that I know is true] ) return;" where the condition is something the compiler can't determine on compile time, then the compiler has no choice but to compile my block of code, even though I know it won't be run. In this case, the program goes something like 3x slower, despite the fact that this block of code will never be run! So frustrating! I have no idea why this is happening.
3. This block of code is IDENTICAL to a block of code run elsewhere in the program. One of the blocks can be in the program without causing the decrease in speed, but copy-paste the block to a different location, and it goes into super-slow mode again.
I'd be happy to answer any other questions or provide other information that may be useful to anyone trying to figure this out for me. Has anyone else ever experienced this kind of sharp decrease in performance due to seemingly nothing?
I am compiling and running this program using NIH's program ImageJ, found at ImageJ
- By Steven Miller in forum Advanced JavaReplies: 5Last Post: 02-08-2011, 11:41 PM
- By welikedogs in forum New To JavaReplies: 4Last Post: 11-03-2010, 07:17 PM
- By senca in forum New To JavaReplies: 1Last Post: 03-06-2010, 09:26 PM
- By p0rnstar in forum New To JavaReplies: 22Last Post: 01-22-2010, 02:57 PM
- By karingulanagaraj in forum New To JavaReplies: 7Last Post: 08-11-2008, 05:11 AM