hideakitai / ArtNet

Art-Net Sender/Receiver for Arduino (Ethernet, WiFi)
MIT License
257 stars 52 forks source link

Callback call frequency not homogenous ? #82

Closed MrFrangipane closed 10 months ago

MrFrangipane commented 10 months ago

Hi,

I have a new question concerning how the callbacks are called.

I am trying to figure out how many universes an RP2040 can handle.

I created 6 callbacks and registered them.

I was experiencing strange framerates, so I put counters inside each callback.

This is how many times each callback is called

Elapsed ms loop() count callbacks [0-5] call count total callbacks calls
5000 307 137 143 4 0 0 1 285
5000 299 180 78 25 3 2 2 290
5000 305 176 75 24 4 4 4 287
5000 304 155 84 19 12 5 12 287
5000 307 155 78 23 10 7 11 284

Is it something that makes sense to you ?

The (basic) sketch is here

Thank you very much for help

MrFrangipane commented 10 months ago

Update

When the fps is within budget (ie. 15 fps for 6 universes), the callbacks are called equitably

5000 ms elapsed. loopCount=558 universeCounts 75 75 75 66 74 24 total 389
5000 ms elapsed. loopCount=559 universeCounts 74 75 74 67 75 23 total 388
5000 ms elapsed. loopCount=559 universeCounts 75 75 75 60 73 21 total 379
5000 ms elapsed. loopCount=559 universeCounts 74 74 74 62 71 25 total 380
5000 ms elapsed. loopCount=559 universeCounts 75 75 73 54 74 16 total 367
5000 ms elapsed. loopCount=559 universeCounts 75 75 74 58 74 20 total 376
5000 ms elapsed. loopCount=559 universeCounts 74 74 74 70 75 25 total 392

Still, I don't understand why when over budget the calls are not equitably lower for all callbacks

hideakitai commented 10 months ago

There are multiple possibilities. ArtNet library handles packets one by one if received. The loop count is not related to the count of the callback. Only when the packet has received && artnet.parse() has called, the callback is called.

It is recommended that measurements be taken without processing other than ArtNet communication first (littlefs, neopixel, etc.).

MrFrangipane commented 10 months ago

Thank you for your response,

I figured a lot of factors can cause that behaviour.

I'll close the issue :)