circuitpython/supervisor
Jeff Epler 568636d562 run_background_tasks: Do nothing unless there has been a tick
This improves performance of running python code by 34%, based
on the "pystone" benchmark on metro m4 express at 5000 passes
(1127.65 -> 1521.6 passes/second).

In addition, by instrumenting the tick function and monitoring on an
oscilloscope, the time actually spent in run_background_tasks() on
the metro m4 decreases from average 43% to 0.5%. (however, there's
some additional overhead that is moved around and not accounted for
in that "0.5%" figure, each time supervisor_run_background_tasks_if_tick
is called but no tick has occurred)

On the CPB, it increases pystone from 633 to 769, a smaller percentage
increase of 21%.  I did not measure the time actually spent in
run_background_tasks() on CPB.

Testing performed: on metro m4 and cpb, run pystone adapted from python3.4
(change time.time to time.monotonic for sub-second resolution)

Besides running a 5000 pass test, I also ran a 50-pass test while
scoping how long an output pin was set.  Average: 34.59ms or 1445/s on m4,
67.61ms or 739/s on cbp, both matching the other pystone result reasonably
well.

import pystone
import board
import digitalio
import time

d = digitalio.DigitalInOut(board.D13)
d.direction = digitalio.Direction.OUTPUT

while True:
    d.value = 0
    time.sleep(.01)
    d.value = 1
    pystone.main(50)
2019-11-18 11:26:48 -06:00
..
messages Support internationalisation. 2018-08-07 14:58:57 -07:00
shared run_background_tasks: Do nothing unless there has been a tick 2019-11-18 11:26:48 -06:00
stub Remove unused static function 2019-09-06 11:06:02 -04:00
cpu.h Mark pointers in cpu registers as in use. 2018-07-03 05:45:50 -07:00
filesystem.h flush flash filesystem once a second 2019-03-20 12:21:36 -04:00
flash.h Rework flash flush so it preserves the cache 2019-04-03 18:28:27 -07:00
flash_root_pointers.h Move atmel-samd to tinyusb and support nRF flash. 2018-11-08 17:25:30 -08:00
memory.h Hook up the terminal based on the first display. 2019-01-31 11:42:14 -08:00
port.h Add functions to get top and limit stack 2019-10-18 11:04:45 +02:00
serial.h Move atmel-samd to tinyusb and support nRF flash. 2018-11-08 17:25:30 -08:00
spi_flash_api.h Move atmel-samd to tinyusb and support nRF flash. 2018-11-08 17:25:30 -08:00
supervisor.mk Supervisor: move most of systick to the supervisor 2019-11-18 11:01:23 -06:00
usb.h Move atmel-samd to tinyusb and support nRF flash. 2018-11-08 17:25:30 -08:00