Using loop Vs "write the list" performan

Currently, I am trying to remake the IBM duinoTag to be based on MilesTag data, which expand from a 4-cell array to 7 cell. (What happen is that it reads the binary data and store into the array) Thus, I am wondering, in terms of arduino, would there be worse performance when using loop in comparison to write it all out. (from what I can gather, they should have the same T(n) of linear time)

What I am doing is this:

for (int i=0; i<=6; i++){
    who[i]= pulseIn(sensorPin, LOW);
}

instead of:

  who[0]   = pulseIn(sensorPin, LOW);
  who[1]   = pulseIn(sensorPin, LOW);
  who[2]   = pulseIn(sensorPin, LOW);
  who[3]   = pulseIn(sensorPin, LOW);
  who[4]   = pulseIn(sensorPin, LOW);
  who[5]   = pulseIn(sensorPin, LOW);
  who[6]   = pulseIn(sensorPin, LOW);

Jesterage--

The second example will probably be faster, but only at most an unnoticeable microsecond or two. I would personally never use repeated statements in lieu of the loop, because (a) the loop is more concise, and (b) cut-and-paste code is more prone to error.

Mikal

In that case I have to go with the second one, since I will be sending and receiving IR signals, with each signal at around hundreds of microseconds for 1s and 0s.

A microsecond or so would not make any difference at data rates of hundreds of microseconds. And I think Mikal was being conservative, the loop would add about 5 clock cycles per iteration, just over ¼ of a microsecond for a 16mhz board

If memory space is an issue, then surely the first is better ;-)

If the microsecond differ is not that high, than yeah.. I will stick with loops. More professional.

BTW, is there anything else that I should keep in mind when programming a 16mhz microcontroller, compare to a full flege desktop program/web app, in order to maximize the performance?

is there anything else that I should keep in mind when programming a 16mhz microcontroller, compare to a full flege desktop program/web app, in order to maximize the performance?

First of all, it's probably not as serious a problem as you think. A 16MHz AVR will give a multi-GHz desktop a good challenge when it comes to things like examining the state of an IO pin (you won't BELIEVE how much IO instructions slow down a modern desktop CPU, if you look into it!)

There was a little bit of discussion here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235782102

The biggest things are: 1) Avoid floating point. 2) Use the smallest possible data type (byte instead of int, int instead of long...)

So far, having read the forums for a couple of years, I think I've seen more problems caused by the Arduino being faster than people expected, rather than slower. The most common example:

while (!Serial.available())
  ; Wait for data to show up
c1 = Serial.read();  // get first char
c2 = Serial.read();  // get second char

The problem is that the second character takes a virtual eternity to arrive (1ms at 9600bps) compared to the speed of Arduino, so it's NOT THERE YET for the second read...