【ESP32】计算性能测试
2017-07-201.4万
AI 快速预览详细
本文通过计算圆周率来测试ESP32、ESP8266和PYB V10的计算性能。结果显示,ESP32在不同位数的计算时间上明显优于其他两个设备。例如,在计算500位数时,ESP32仅需0.078秒,而ESP8266需要0.65秒,PYB V10需要0.11秒。ESP32的主频为240MHz,SRAM 520KB,Flash 16Mb,带有蓝牙和Wifi。这些参数使得ESP32在高性能计算应用中表现出色。
ESP32的性能不错,主频240MHz,SRAM 520KB,Flash 16Mb,带有蓝牙和Wifi。但是ESP32到底有多快,我做了一个测试,将ESP32、ESP8266和PYBV10做对比,在它们上计算圆周率,通过计算时间比较计算性能。
从上表可以看出,ESP32的性能的确非常不错。 |





[code]'''文件:pi.py
说明:用MicroPython计算任意精度圆周率计算
作者:未知
版本:
时间:
修改:邵子扬
2016.5
'''
import time
def pi(places=10):
# 3 + 3*(1/24) + 3*(1/24)*(9/80) + 3*(1/24)*(9/80)*(25/168)
# The numerators 1, 9, 25, ... are given by (2x + 1) ^ 2
# The denominators 24, 80, 168 are given by (16x^2 -24x + 8)
extra = 8
one = 10 ** (places+extra)
t, c, n, na, d, da = 3*one, 3*one, 1, 0, 0, 24
while t > 1:
n, na, d, da = n+na, na+8, d+da, da+32
t = t * n // d
c += t
return c // (10 ** extra)
def pi_t(n=10):
t1=time.ticks_us()
t=pi(n)
t2=time.ticks_us()
print('elapsed: ', time.ticks_diff(t2,t1)/1000000, 's')
return t
[/code]