mulander / evolutionchamber

Automatically exported from code.google.com/p/evolutionchamber
0 stars 0 forks source link

EcState.java:isSatisfied(EcState) CPU usage #69

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I was doing some profiling in JVisualVM for fun when I noticed that the 
isSatisfied method in EcState.java was topping the charts in terms of CPU 
usage. It seems to be most noticeable when only final information is given (no 
waypoints). Not a major problem, but I felt like playing around with it anyway 
:)

After a bit of tweaking, I found I was able to get a ~5% decrease in CPU time 
by moving the waypoints loop to the end of the method and switching the ands 
from bitwise to short-circuit evaluating. I guess I could have factored the if 
statements into a single return, but I thought that would damage readability.

Attached is a patch with the changes I made so others can test them out. I 
tested it as best I could for any logical errors, and there seemed to be no 
change in functionality. But of course since I'm not the primary programmer I 
may have missed something.

Keep up the good work all!

Cheers,
Derek Guenther

Original issue reported on code.google.com by spacepir...@gmail.com on 25 Oct 2010 at 1:45

Attachments:

GoogleCodeExporter commented 9 years ago
Merged. Thanks for the contribution!

Original comment by Frit...@gmail.com on 25 Oct 2010 at 3:56