I wonder how much time takes the if test on WiFi.softAPgetStationNum(). I could, for example, use a timer, to test, say every 10 seconds, the state of WiFi.softAPgetStationNum() and set a global boolean variable accordingly. Then, inside the loop(), the test would be on that boolean variable.

In other words, I wonder if WiFi.softAPgetStationNum() is just a "property" of the WiFi object that we read or if it is a method that takes time to execute each time it is invoked!

User mini profile

I'm fairly new to the forum too, but I think I can help you with this. Just put the following code in the beginning of the function and it will give you the execution time of the command you are asking for:

micros()

Code: Select allunsigned long functionStartTime;unsigned long functionEndTime;unsigned long total_FunctionProcessingTime; // Declare these values to get the time for your function

Connect to a wifi first in the setup function and you can test execution time with this same function at setup for no connection and then inside the loop for connection times to learn the averages. Don't forget to clear your variables from time to time to prevent an overflow. You can just run the code before the // resume your normal code line and place any other function in between to test the execution times. Enjoy!