Code: Select all
@micropython.viper
def togglePerformance3c():
start = pyb.millis()
odr = ptr16(stm.GPIOA + stm.GPIO_ODR)
for _ in range(2000000):
odr[0] ^= 1 << 13 # PA13 = LED_RED
time = pyb.elapsed_millis(start)
count = round(2e9 / time)
print('Counted: {:10,} (viper3) (time={}ms)'.format(count, time))
@micropython.viper
def togglePerformance3d():
start = pyb.millis()
bsrrl = ptr16(stm.GPIOA + stm.GPIO_BSRRL)
bsrrh = ptr16(stm.GPIOA + stm.GPIO_BSRRH)
for _ in range(2000000):
bsrrl[0] = 1 << 13
bsrrh[0] = 1 << 13
time = pyb.elapsed_millis(start)
count = round(4e9 / time) # 2 toggles per iteration
print('Counted: {:10,} (viper4) (time={}ms)'.format(count, time))
viper 3c: 2,020,202
viper 3d: 6,700,168
Version 3d is only a factor 2 off Dave's assembler version.