serial print speed

Hi,

I have a question.... i' ve tested my genuino mega 2560 for serial.print speed with this simply code:

int t = 0, t1 = 0;

void setup() {
Serial.begin(9600);
}

void loop() {
t = micros();
Serial.println(t1);
t1 = micros() - t;
}

On the serial monito i've read

0
72
116
160
160
156
160
156
168
156
160
156
160
156
176
5152
6232
6232
6232
6232
6232
6232
6232
6232
6232
6232
6232
6232
6232
6232
6232
6232
6232
6232
6232
6232

why speed decrease? How can I keep the first transfer time for ever?

Thank u very much (and excuse me for my bad english)

Change this Serial.begin(9600); to Serial.begin(115200); then retest and see if you can figure it out.

why speed decrease? How can I keep the first transfer time for ever?

The first few time all print has to do is stick the characters in the buffer. Going out from the buffer to the Serial line is interrupt driven. So it just copies chars into the buffer and returns. Super quick.

Later once the buffer is full, print has to wait while chars are sent out to make room for the new stuff. That takes some time. If you increase the baud rate it goes faster.