Pages: 1 [2]   Go Down
Author Topic: Combining Serial prints ... HELP!  (Read 1413 times)
0 Members and 1 Guest are viewing this topic.
Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1729
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: October 09, 2012, 03:54:56 pm by Tom Carpenter » Logged

~Tom~

Pages: 1 [2]   Go Up
Jump to: