【FireBeetle 2 ESP32 C6】几种esp32性能对比测试
<p>为了了解esp32c6的性能,在手上的几个开发板上,做了一个简单的性能对比。编写了一小段测试程序,分别计算分形、圆周率等。测试不是太严谨,只作为一个参考。</p><p> </p>
<p>从左到右分别是:rpi PICO、esp32s2、esp32s3、esp32c3、esp32c6,硬件方面的对比请参考<a href="https://bbs.eeworld.com.cn/thread-1279701-1-1.html">【FireBeetle 2 ESP32 C6】esp32系列芯片对比 </a>这个帖子。</p>
<p> </p>
<p> </p>
<p> </p>
<p>测试程序如下,包括了加法、乘法(除法)、分形、圆周率等计算程序,分别计算每项测试所用的时间,时间越短代表性能越好。为了保证在相同的环境下进行测试,在测试前,将开发板的固件都升级到最新的测试版本。</p>
<pre>
<code class="language-python">from time import ticks_ms, ticks_diff
from machine import freq
from platform import platform
import gc
def run(func, *param):
gc.collect()
t1 = ticks_ms()
if param == None:
func()
else:
func(*param)
t2 = ticks_ms()
print('calc time:', ticks_diff(t2, t1), 'ms\n')
def mandelbrot(iter=80):
def in_set(c):
z = 0
for i in range(iter):
z = z * z + c
if abs(z) > 4:
return False
return True
for v in range(31):
for u in range(81):
if in_set((u / 30 - 2) + (v / 15 - 1) * 1j):
print(' ', end='')
else:
print('#', end='')
print()
def pi(places=100):
# 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 add_test(N=100000, A=1.1, B=2.2):
for i in range(N):
A + B
def mul_test(N=100000, A=1.1, B=2.2):
for i in range(N):
A * B
print('\nSystem:', platform())
print('Frequency:', freq())
print('Memory:', gc.mem_free()+gc.mem_alloc())
print('\nBegin test\n')
print('Calculate 1000000 additions')
run(add_test, 1000000)
print('Calculate 1000000 multiplications')
run(mul_test, 1000000)
print('Calculate 1000000 divisions')
run(mul_test, 1000000, 12345, 1/13)
print('Calculate mandelbrot with iterations 200')
run(mandelbrot, 200)
print('Calculate 1000 digits of pi')
run(pi, 1000)
print('Calculate 10000 digits of pi')
run(pi, 10000)</code></pre>
<p> </p>
<p> </p>
<p source-line="87" source-line-end="88" style=" color: rgb(50, 55, 63); letter-spacing: normal; orphans: 2; widows: 2; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255)"><strong>测试结果</strong>(时间单位是ms)</p>
<p source-line="87" source-line-end="88" style=" color: rgb(50, 55, 63); letter-spacing: normal; orphans: 2; widows: 2; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255)"> </p>
<table source-line="89" source-line-end="99" style=" border-collapse: collapse; border: 1px solid rgb(220, 220, 220); background-color: rgb(255, 255, 255); color: rgb(50, 55, 63); letter-spacing: normal; orphans: 2; widows: 2; word-spacing: 0px; white-space: normal">
<thead>
<tr>
<th style=" color: rgb(50, 55, 63); border-style: solid; border-color: rgb(220, 220, 220); border-image: initial; background-color: rgb(247, 247, 247)"> </th>
<th style="color: rgb(50, 55, 63); border-style: solid; border-color: rgb(220, 220, 220); border-image: initial; background-color: rgb(247, 247, 247); text-align: center;">esp32c3</th>
<th style="color: rgb(50, 55, 63); border-style: solid; border-color: rgb(220, 220, 220); border-image: initial; background-color: rgb(247, 247, 247); text-align: center;">esp32c6</th>
<th style="color: rgb(50, 55, 63); border-style: solid; border-color: rgb(220, 220, 220); border-image: initial; background-color: rgb(247, 247, 247); text-align: center;">esp32s2</th>
<th style="color: rgb(50, 55, 63); border-style: solid; border-color: rgb(220, 220, 220); border-image: initial; background-color: rgb(247, 247, 247); text-align: center;">es32s3</th>
<th style="color: rgb(50, 55, 63); border-style: solid; border-color: rgb(220, 220, 220); border-image: initial; background-color: rgb(247, 247, 247); text-align: center;">rpi PICO</th>
</tr>
</thead>
<tbody>
<tr>
<th style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: left;">频率</th>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">160MHz</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">160MHz</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">160MHz</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">160MHz</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">125MHz</td>
</tr>
<tr style="background-color: rgb(247, 247, 247)">
<th style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: left;">ram</th>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">203264</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">342528</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">7797248</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">252416</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">233024</td>
</tr>
<tr>
<th style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: left;">加法 1000000 次</th>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">5798</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">5642</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">7693</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">6403</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">10392</td>
</tr>
<tr style="background-color: rgb(247, 247, 247)">
<th style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: left;">乘法 1000000 次</th>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">5955</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">5555</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">7670</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">6334</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">10257</td>
</tr>
<tr>
<th style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: left;">除法 1000000 次</th>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">6263</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">5937</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">7307</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">5884</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">10313</td>
</tr>
<tr style="background-color: rgb(247, 247, 247)">
<th style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: left;">mandelbrot (迭代次数 200)</th>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">4526</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">3862</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">8154</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">4122</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">7331</td>
</tr>
<tr>
<th style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: left;">计算圆周率 1000 位</th>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">407</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">420</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">675</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">463</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">562</td>
</tr>
<tr style="background-color: rgb(247, 247, 247)">
<th style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: left;">计算圆周率 10000 位</th>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">32997</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">30260</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">60229</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">36467</td>
<td style="color: rgb(50, 55, 63); border: 1px solid rgb(220, 220, 220); text-align: center;">66017</td>
</tr>
</tbody>
</table>
<p source-line="100" source-line-end="101" style=" color: rgb(50, 55, 63); letter-spacing: normal; orphans: 2; widows: 2; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255)"> </p>
<p>从测试结果可以看到,esp32c6在性能上,相比esp32c3略有提升,综合起来有5-10%左右。几种esp32芯片的性能差异都不算太大,但risc-v内核的esp32cx系列还是略有优势。这样看起来,后续的H系列(低成本低功耗无线通信)和P系列(高性能高安全通用型)也会比较值得期待。</p>
<p> </p>
<p> </p>
<p>楼主总结的esp32性能对比内容非常实用,对挑选板子非常具有参考价值,感谢楼主的分享</p>
<p>esp32c3到esp32c6,为什么中间跨度这么大? </p>
秦天qintian0303 发表于 2024-4-28 09:14
esp32c3到esp32c6,为什么中间跨度这么大?
<p>厂家任性啊</p>
页:
[1]