一项技术对比测试在STM32F446微控制器上评估了Embassy/Rust异步模型与FreeRTOS/C框架的性能表现1。该测试平台运行频率为180MHz,通过实现LED闪烁、按钮中断、消息队列等相同功能的应用程序,从中断延迟、程序大小、内存使用和编程易用性四个维度进行量化评测1。
测试结果显示Embassy/Rust在中断性能上优势明显1。Embassy/Rust的中断时间为1.450μs,中断延迟为3.738μs,均低于FreeRTOS/C的2.962μs和4.973μs1。虽然FreeRTOS/C采用的抢占式多线程在上下文切换速度上略快(2.011μs相比Embassy的2.288μs),但这一优势被其中断处理时间的劣势所抵消1。在程序大小和内存占用方面,Embassy/Rust同样表现更优,这源于其编译器仅在await点之间存储必要变量1。Embassy采用的合作式多任务设计相比FreeRTOS的抢占式方案提供了更高的代码简洁性和编程体验1。
A technical comparison of Embassy, a Rust-based asynchronous runtime, and FreeRTOS, a C-based real-time operating system, reveals significant performance advantages for the Rust implementation on embedded microcontrollers.1
The evaluation was conducted on an STM32F446ZET6 microcontroller running at 180 MHz, with tests measuring interrupt latency, program size, static memory consumption, and programming ease.1 Embassy achieved an interrupt response time of 1.450 microseconds with a total interrupt latency of 3.738 microseconds, compared to FreeRTOS's 2.962 microseconds for interrupt handling time and 4.973 microseconds for total latency.1 The Rust-based framework demonstrated superior program size efficiency, attributed to the compiler generating futures that store only variables between await points rather than entire thread contexts.1
While FreeRTOS employs preemptive multithreading and exhibits marginally faster context switching at 2.011 microseconds versus Embassy's 2.288 microseconds, this advantage is offset by FreeRTOS's slower interrupt handling performance.1 Embassy utilizes a cooperative multitasking model without preemption.1 Across all measured metrics, Embassy emerged as the more efficient solution, offering not only quantifiable performance improvements but also cleaner code and a superior programming experience compared to its C counterpart.1
评论
还没有评论,欢迎留下第一条。