Combining Serial prints ... HELP!
Topic: Combining Serial prints ... HELP!
(Read 3259 times)
Once the magic blue smoke is released, it won't go back in!
Re: Combining Serial prints ... HELP!
Oct 09, 2012, 10:49 pm
: Oct 09, 2012, 10:54 pm by Tom Carpenter
Just for the sake of interest, the method using multiple print() calls is faster than the sprintf() method (in one simple test).
For a loop of 100 calls to printing the data for each, the results are:
multiple print()'s : 210556 us
sprintf() : 210972 us
That is at 115200 baud and the same group of calls as in that snippet of code you posted.
For a loop of 10000 calls to printing the data for each, the results are:
multiple print()'s : 23378412 us
sprintf() : 22798020 us
Interesting, sprintf() seems to have recovered. I think the first test may have been biased as for the first few iterations sprintf() had more to print as micros() had a larger value (more decimal digits)
But yeah as has been pointed out:
115,200 baud = 11520 bytes per second = 11.52 bytes per millisecond, not including the time it takes to get the data and load it into the buffer etc.