0

Is there a way to measure the performance of a PICO? I want to add serveral attachements such as PCA9685 with servos & LED's and attach motion sensors to the PICO, but I'm concerned that I might be slow in responding to interrupts or to providing instructions to the servos by asking the PICO to do too much.

The instructions to manipulate the servos come from MQTT in the form of subscribe. The PICO also publishes it's sensor info via MQTT.

Currently all the code is in Micro Python which I understand is slow compared to C/C++. However, it's very easy to implement things so I would prefer to stay with it rather than reqriting code in C/C++

Thanks.

quinn
  • 177
  • 1
  • 2
  • 13

1 Answers1

0

Easiest way would just be to measure times at different points. To cut down on keeping track of all these, you could just create a performance timer class like so

class PerformanceTimer:
  def __init__(self):
    self.start = millis()
    self.value = 0
  def measure():
    self.value = millis() - self.start
  def reset():
    self.value = 0;
    self.start = millis();

and then call it around sections of code you want to measure:

   myMeasure1 = PerformanceTimer()
   ## critical code section
   myMeasure1.measure()     # Calculate the difference
   print(myMeasure1.value)  # Do whatever you want with the value you recorded
Dacoolinus
  • 388
  • 1
  • 10