Skip to content

Conversation

@bablokb
Copy link

@bablokb bablokb commented Jul 5, 2022

This commits adds an optional parameter update=True to add_values(). The default keeps the current behavior. Setting update=False results in primitives not being updated, this has to be done manually after adding a number of values.

Timing tests with a slightly modified version of examples/display_shapes_sparkline_simpletest.py:

s = time.monotonic() for _ in range(10): sparkline1.add_value(random.uniform(0, 10)) print("%f" % (time.monotonic()-s)) 

vs:

s = time.monotonic() for _ in range(10): sparkline1.add_value(random.uniform(0, 10),update=False) sparkline1.update() print("%f" % (time.monotonic()-s)) 

The first version maxes out at about 2 seconds after the limit of 40 values is reached, the second version maxes out at 0.2 seconds. Figures measured with a PyPortal.

Copy link

@kmatch98 kmatch98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, gives more redraw flexibility when adding multiple points.

@kmatch98 kmatch98 merged commit cdef091 into adafruit:main Jul 5, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jul 6, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k to 1.12.8 from 1.12.7: > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#62 from tom24/udpfixes Updating https://github.com/adafruit/Adafruit_CircuitPython_Dash_Dis to 1.1.7 from 1.1.6: > Merge pull request adafruit/Adafruit_CircuitPython_Dash_Dis#5 from Neradoc/add-requirements Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes to 2.5.0 from 2.4.6: > Merge pull request adafruit/Adafruit_CircuitPython_Display_Shapes#50 from bablokb/sparkline_opt Updating https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer to 0.2.0 from 0.1.4: > Merge pull request adafruit/Adafruit_CircuitPython_HTTPServer#7 from karlfl/main Updating https://github.com/adafruit/Adafruit_CircuitPython_OAuth2 to 1.0.10 from 1.0.9: > Merge pull request adafruit/Adafruit_CircuitPython_OAuth2#8 from tcfranks/main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants