I was doing some comport profiling using an Arduino and Firmata. I noticed that at the default poll time of 1ms, that there were many fruitless calls to comport_tick() before any bytes where read. And that the bytes are always read and written in clusters, no matter the poll time.
The profile marks are:
"t" - comport_tick() called
"s" - entered while(select()) loop
"r%i" - read() %i bytes
"w%i" - write() %i bytes
" " - end of comport_tick() reached
Default poll time of 1ms:
reading only:
t t t t t t t t t t t t t t tsr6 t t t t t t t t t t t t t t t tsr15 t t t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t t t t t tsr9 t t t t t t t t t t t t t tsr14 t t t t t t t t t t t t t t t t t tsr16 t t t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t t t tsr17 t t t t t t t t t t t t t t t t tsr7 t t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t t t t tsr8 t t t t t t t t t t t t t t t tsr16 t t t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t t t tsr18 t t t t t t t t t t t t t t t tsr18
reading and writing:
t t t t t tw3 t t t t t t t t t tsr18w3 t t t t t t t t t tw3 t t t t t tsr18 t t t tw3 t t t t t t t t t tw3 t tsr13 t t t t t t t tw3 t t t t t t t tsr11 t tw3 t t t t t t t t t tw3 t tsr17 t t t t t t t tw3 t t t t t t t t t tsr16w3 t t t t t t t t t tw3 t t t t t tsr18 t t t tw3 t t t t t t t t t tw3 t tsr18 t t t t t t t tw3 t t t t t t t tsr16 t tw3 t t t t t t t t t tw3 t t t tsr8 t t t t t tw3 t t t t t t t t t tsr18w3 t t t t t t t t t tw3 t t t t t tsr18 t t t tw3 t t t t t t t t t tw3 t tsr16 t t t t t t t tw3 t t t t t t t tsr17 t tw3 t t t t t t t t t tw3 t t t tsr18 t t t t t tw3 t t t t t t t t t tsr8w3 t t t t t t t t t tw3 t t t t tsr16 t t t t tw3 t t t t t t t t t tw3 tsr18 t t t t t t t t tw3 t t t t t t tsr18 t t tw3 t t t t t t t t t tw3 t t tsr18 t t t t t t tw3 t t t t t t t t tsr18 tw3 t t t t t t t t t tw3 t t t t tsr12 t t t t tw3 t t t t t t t t t tw3 tsr12 t t t t t t t t tw3 t t t t t t tsr18 t t tw3 t t t t t t t t t tw3 t t t tsr18 t t t t t tw3 t t t t t t t t tsr18 tw3 t t t t t t t t t tw3 t t t t tsr18 t t t t tw3 t t t t t t t t t tw3 tsr12 t t t t t t t t tw3 t t t t t t tsr12
Switching the poll time to 10ms got a much more efficient profile while mostly reading and writing at the same pace:
reading only:
tsr18 tsr18 t tsr6 tsr18 t tsr18 tsr18 t tsr18 t tsr18 tsr6 t tsr18 t tsr18 tsr18 t tsr18 tsr18 t tsr9 t tsr15 tsr17 t tsr16 tsr18 t tsr18 t tsr16 tsr8 t tsr18 tsr18 t tsr15 t tsr18 tsr18 t tsr6 tsr18 t tsr18 t tsr18 tsr18 t tsr18 tsr13 t tsr11 t tsr18 tsr18 t tsr18 tsr18 t tsr13 t tsr11 tsr16 t tsr17 tsr18 t tsr18 t tsr18 tsr6 t tsr18 tsr18 t tsr15 t tsr18 tsr18 t tsr12 tsr12 t tsr18 t tsr18 tsr18 t tsr18 tsr14 t tsr10 t tsr18 tsr18 t tsr18 tsr18 t tsr18 t tsr7 tsr15 t tsr17 tsr18 t tsr18 t tsr18 tsr11 t tsr13 tsr18 t tsr15 t tsr18 tsr18 t tsr15 tsr9 t tsr18 t tsr18 tsr18 t tsr18 tsr18 t tsr6 tsr18 t tsr18 t tsr18 tsr18 t tsr18 t tsr7 tsr14 t tsr18 tsr18 t tsr18 tsr18 t tsr12 t tsr12 tsr18 t tsr15 t tsr18 tsr18 t tsr18 tsr6 t tsr18 t tsr18 tsr18 t tsr18 tsr18 t tsr9 t tsr15 tsr18 t tsr18 tsr18 t tsr18 t tsr10 tsr11 t tsr18 tsr18 t tsr18 t tsr18 tsr18 t tsr6 tsr17 t tsr16 tsr18
reading and writing:
tsr18w3 tw3 tsr18w3 tw3 tsr15w3 tsr18w3 tw3 tsr8w3 tsr16w3 tw3 tsr18w3 tw3 tsr18w3 tsr18w3 tw3 tsr18w3 tsr12w3 tw3 tsr12w3 tw3 tsr18w3 tsr18w3 tw3 tsr18w3 tsr18w3 tw3 tsr13w3 tw3 tsr11w3 tsr17w3 tw3 tsr16w3 tw3 tsr18w3 tsr18w3 tw3 tsr18w3 tsr8w3 tw3 tsr16w3 tw3 tsr18w3 tsr18w3 tw3 tsr15w3 tsr18w3 tw3 tsr9w3 tw3 tsr15w3 tsr18w3 tw3 tsr18w3 tsr18w3 tw3 tsr18w3 tsr16w3 tw3 tsr8w3 tw3 tsr18w3 tsr18w3 tw3 tsr18w3 tsr18w3 tw3 tsr17w3 tw3 tsr8w3 tsr15w3 tw3 tsr17w3 tsr18w3 tw3 tsr18w3 tw3 tsr18w3 tsr9w3 tw3 tsr15w3 tsr18w3 tw3 tsr18w3 tw3 tsr15w3 tsr18w3 tw3 tsr14w3 tsr10w3 tw3 tsr18w3 tw3 tsr18w3 tsr18w3 tw3 tsr18w3 tw3 tsr18w3 tsr6w3 tw3 tsr18w3 tsr18w3 tw3 tsr18w3 tsr18w3 tw3 tsr18w3 tw3 tsr8w3 tsr14w3 tw3 tsr17w3 tw3 tsr18w3 tsr18w3 tw3 tsr18w3 tsr14w3 tw3 tsr10w3 tsr18w3 tw3 tsr18w3 tw3 tsr15w3 tsr18w3 tw3 tsr18w3 tsr6w3 tw3 tsr18w3 tw3 tsr18w3 tsr18w3 tw3 tsr18w3 tsr18w3 tw3 tsr9w3 tw3 tsr15w3 tsr18w3 tw3 tsr18w3 tsr18w3 tw3 tsr18w3 tw3 tsr15w3 tsr8w3 tw3 tsr16w3
So since 10ms is also the default poll time for most HID devices, and it seems that for most uses of [comport] (i.e. arduinos and other serial ports 115200 baud or less) that 10ms makes more sense. 10ms polling is going to give the data as fast as 1ms polling with a lot less CPU time wasted. Then for special applications or very high speed serial ports, people can still use the [delay( message to set polling to 1ms or whatever.
.hc
----------------------------------------------------------------------------
You can't steal a gift. Bird gave the world his music, and if you can hear it, you can have it. - Dizzy Gillespie