Action (orders) operating time

Hello everybody,
I would like to know if anyone knows exactly the time that each action or order that i write during programming would the micro-controller take to perform (I am using an Arduino Due Micro-controller).

Like (Int sensorValue = ....... or Array = ......, etc )
Thanks a lot

Very difficult to say - it depends on what you (and the compiler) define as an action.

You can look at the generated code, and look at the number of cycles per instruction, listed in the processor datasheet.

However, it can be tricky - the ARM is a very clever architecture.

You can't simply define it that way. You could use micros () before the statement and micros() after that and calculate the difference in microseconds. That gives a reasonable guestimation of the time for a specific statement.
The C language statemnts are translated into machine code instructions which might call all kinds of subroutines. The optimizer will try to use as many registers as possible for faster operation. But if you use many variables there is a moment that register will have to be saved in memory to free up registers for other instructions.
So you cannot simply state int c = xxx; has a fixed duration.

Alright..
Thank you very much guys .. :slight_smile:

Note that the act of measuring it will affect it, and the shorter the piece of code that you are timing the less accurate your measurement will be.

On an Arduino, anything that interacts with external devices will usually (IMO) be massively slower than code that is purely crunching numbers, and unless you're solving a very computationally intensive problem the execution time of the code itself is only going to matter in the odd corner cases where you're trying to achieve high speed input or output.