Arduino Processing Power & Time

How long would it take the Arduino Pro Mini with an ATMega 328 to follow this code?

for (int i = 0; i <= 9; i++)
						for (int j = 0; j <= 3; j++)
							for (int k = 4; k <= 7; k++)
								if (RunningAvgArray[i] > (2 + RunningAvgArray[i + j]) && (RunningAvgArray[i + k] > (2 + RunningAvgArray[i + j])))
									bouncetime = millis();

Sorry about the awkward spacing. This was the fault of the Codebender autoformat.

To figure out the time it takes...the easy way is to put in a counter and run the time on your actual hardware. You can measure this easier than anyone else. Psuedocode to follow:

unsigned long counterVariable; 
unsigned long timeSpent; 

counterVariable = micros(); // or you can use millis();


timeSpent = micros() - counterVariable;
Serial.print("My code took " + timeSpent + " microseconds to run");

//Code is completely untested and is intended only to show possible flow to complete task.

As for power...that's a question I don't know how to answer. How much does it matter? Your energy usage is approximately the estimated average power to run the arduino times the amount of time that your code runs. (answer in watt-seconds)

I dont have an arduino anymore lol

chessy: I dont have an arduino anymore lol

Then, the answer is simple. That code will take forever to execute.



So, IMO this is not a ‘ha ha’ theme … a lots of time gets wasted when non-newbies that should know better post with an inappropriate title.

I respect your question, but how easy it would have been to just title this,
“Request code timing from UNO user”
and to put in the millis() command so that anyone could run it and post the results. Then you could have edited the title to,
" Request code timing from UNO user"