Re: [NXC] Optimize this code?
Posted: 01 Feb 2012, 22:05
A couple of things:
1) Before you ask someone to "optimize some code", you ought to make it properly formatted. I had to do that just to figure out what was going on.
2) Without doing the actual optimization, I tried running the compiler at Opt=6. That shortened the code some.
3) Again, without doing any optimization, it won't run with more than 105 particles. I get a "File Error", with could mean either a bad index, or, more likely, out of memory. The error is down in the main loop somewhere.
4) Indexing into a 2D array (which isn't a 2^n square) is costly. An awful lot of code is done computing the actual byte that you want. There just isn't much that can be done to optimize that code, other than what the compiler is already doing.
1) Before you ask someone to "optimize some code", you ought to make it properly formatted. I had to do that just to figure out what was going on.
2) Without doing the actual optimization, I tried running the compiler at Opt=6. That shortened the code some.
3) Again, without doing any optimization, it won't run with more than 105 particles. I get a "File Error", with could mean either a bad index, or, more likely, out of memory. The error is down in the main loop somewhere.
4) Indexing into a 2D array (which isn't a 2^n square) is costly. An awful lot of code is done computing the actual byte that you want. There just isn't much that can be done to optimize that code, other than what the compiler is already doing.