mclarkk / lifxlan

Python library for accessing LIFX devices locally using the official LIFX LAN protocol.
MIT License
507 stars 116 forks source link

There's a sleep after every send instead of just between repeated #176

Closed exking closed 1 year ago

exking commented 1 year ago

sends, including those of related commands in a batch operation. On a raspberry pi, the sleeps seem to be a lot more expensive than just 0.05 seconds (context switching is very expensive on those tiny Arms), so the whole command ends up taking about 10 seconds to execute. Just assume the LIFX can put up with getting a couple of requests quickly -- we're not sending too many of them.

With the sleep at the end of the loop:

10514,20> time ./get_lights 2 Discovering lights... Found 2 lights: Bedroom (d0:73:d5:26:d2:00) P: 0 (HSBK): (0, 0, 44563, 4000) Porch (d0:73:d5:30:f2:93) P: 0 (HSBK): (0, 0, 3276, 4000)

real 0m9.268s user 0m2.066s sys 0m0.321s

With the last sleep removed:

0-0-18:46:23, Tue Aug 28 tconnors@pi:~/bin (bash) 10514,21> time ./get_lights 2 Discovering lights... Found 2 lights: Bedroom (d0:73:d5:26:d2:00) P: 0 (HSBK): (0, 0, 44563, 4000) Porch (d0:73:d5:30:f2:93) P: 0 (HSBK): (0, 0, 3276, 4000)

real 0m5.613s user 0m1.966s sys 0m0.309s