性能测试(micropython运行环境)

machine_capability.py

#!/usr/bin/env python
# -*- coding: GBK -*-
import utime

def capability(n):             
    r=1           
    t1=utime.ticks_us()                     
    while n>1:                  
        r=r*n                 
        n=n-1                 
    t2=utime.ticks_us()                          
    print('@spend time:', utime.ticks_diff(t2,t1), 'us')                                     
    #return r

if __name__ == '__main__':
    capability(1000)

运行环境:STM32H743VIT6,主频:400MHZ,RAM:1M,FLASH:2M

运行结果:

>>> capability(100)
@spend time: 356 us
>>> capability(1000)
@spend time: 19782 us
>>> capability(50000)
@spend time: 59523436 us
>>> capability(60000)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 7, in capability
MemoryError: memory allocation failed, allocating 68546 bytes

运行环境:ESP32,FLASH:4M

运行结果:

>>> 
MicroPython ESP32_LoBo_v3.2.16 - 2018-05-15 on M5Stack with ESP32
Type "help()" for more information.
>>> capability(100)
@spend time: 3116 us
>>> capability(1000)
@spend time: 135566 us
>>> capability(10000)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 7, in capability
MemoryError: memory allocation failed, allocating 12354 bytes

运行环境:MAIXpy-bit, 主频:400MHZ(可超频至600MHZ)FLASH:128Mbit , SRAM:内置8M byte

运行结果:

MicroPython v0.5.0-22-g7ac6b09bf-dirty on 2020-03-09; Sipeed_M1 with kendryte-k210
Type "help()" for more information.
>>> from machine_capability import*
>>> capability(100)
@spend time: 463 us
>>> capability(1000)
@spend time: 23896 us
>>> capability(50000)
@spend time: 98910354 us
>>> capability(60000)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "machine_capability.py", line 7, in capability
MemoryError: memory allocation failed, allocating 91652 bytes

根据上面性能测试排名:

  1. STM32H743VIT6
  2. MaixPy-bit
  3. ESP32

参考链接:http://bbs.eeworld.com.cn/thread-490119-1-1.html

原文地址:https://www.cnblogs.com/iBoundary/p/12529752.html