Hey everybody,
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

Thanks.