I'm working on optimizing a little java program I made for Christmas. I was testing the amount of time it takes to run the methods and one of them, Snow_AI, is taking 1234567 nano seconds to run.
The issues is with the counter method:
public boolean Count() {
if (CreateCnt > CreateTime) {
CreateCnt = 0;
return true;
} else {
CreateCnt = CreateCnt + 1;
}
return false;
}
This is how I'm making the calls:
MethTmr1 = System.nanoTime();
if (Snw.Count()) {
MethTmr = System.nanoTime();
Snw.Snow_AI();
MethTPS = 1000000000 / (System.nanoTime() - MethTmr);
}
try{
MethTPS1 = 1000000000 / (System.nanoTime() - MethTmr1);
}catch(Exception e){}
when I move the timing calls inside the If statement it changed the time to run to less than 5000. Anyone know why the counter method is causing this to happen?