[color=rgb(12, 147, 228) !important]【瑞萨RA4系列开发板体验】基准性能测试之一:整数计算能力Dhrystone
作者:jf_1137202360
前言
基准测试有很多种,比如常见的coremark,已经有小伙伴测试过了,这里就不再重复测试了。这里采用Dhrystone进行整数性能测试。
过程
添加代码
获取代码 解压classic_benchmarks.tar.gz将\classic_benchmarks\classic_benchmarks\source_code\dhrystone2文件夹复制到自己的工程。 添加代码将\classic_benchmarks\source_code\dhrystone2文件夹复制到工程目录,并添加工程中
移植接口
在上一篇基础上,实现时间获取接口 ra-fsp-examples\example_projects\ek_ra4m2\sci_uart\sci_uart_ek_ra4m2_ep\keil\src\hal_entry.c中
- uint32_t SysTick_Gettime(void)
- {
- return s_time_u32;
- }
复制代码dhry1.c中 注释掉//#include "cpuidh.h" 添加#include <stdint.h> 添加extern uint32_t SysTick_Gettime(void); 原来是以下代码获取之间代码执行时间(S),到全局变量User_Time start_time(); ...... end_time(); User_Time = secs 我们使用SysTick_Gettime来获取时间 我们之前配置systick的中断周期是1mS。 所以可以改为 uint32_t s_stime_u32 = SysTick_Gettime(); ...... uint32_t s_etime_u32 = SysTick_Gettime(); User_Time = (s_etime_u32 - s_stime_u32)/1000.0; void main (int argc, char *argv[]) 改为 void dhry_main(int argc, char *argv[]) 注释掉以下内容
- ///getDetails();
- ///for (i=1; i<10; i++)
- ///{
- /// printf("%s\n", configdata);
- ///}
- ///printf("\n");
-
- ///fprintf (Ap, " #####################################################\n\n");
- ///for (i=1; i<10; i++)
- ///{
- /// fprintf(Ap, "%s \n", configdata);
- ///}
- ///fprintf (Ap, "\n");
复制代码185行 #endif "Register option Selected." 改为 #endif // "Register option Selected." 注释掉452行
- ///local_time();
- ///fprintf (Ap, " #####################################################\n\n");
- ///fprintf (Ap, " Dhrystone Benchmark 2.1 %s via C/C++ %s\n", options, timeday);
- ///fprintf (Ap, " VAX MIPS rating: %12.2lf\n\n",Vax_Mips);
复制代码 注释掉130的内容
- ///if ((Ap = fopen("Dhry.txt","a+")) == NULL)
- /// {
- /// printf(" Can not open Dhry.txt\n\n");
- /// printf(" Press Enter\n\n");
- /// int g = getchar();
- /// exit(1);
- // }
复制代码113行 int nopause = 1; 改为 int nopause = 0;
测试
ra-fsp-examples\example_projects\ek_ra4m2\sci_uart\sci_uart_ek_ra4m2_ep\retarget.c中 修改发送\n时替换为发\r\n
- int fputc(int ch, FILE *f)
- {
- (void)f;
- uint8_t data = (uint8_t)ch;
- /* Your implementation of fputc(). */
- if(data == '\n')
- {
- uart_poll_send('\r');
- }
- uart_poll_send(data);
- return ch;
- }
复制代码hal_entry中 申明 void dhry_main (int argc, char *argv[]); 调用dhry_main(0,0); -O3优化
-Ofast优化
-O2优化
和100MHz的Pentium差不多
总结
优化等级影响较大,O3和Ofast得分一样。
|