STM32的FPU问题

2019-07-20 11:20发布

               我用STM32F301做实验,就计算浮点数的加减乘除,为什么启用FPU反而比不启用FPU计算慢?。下面是我实验的代码,很简单。通过观察小灯的闪烁快慢来看计算速度。

#include "LED.h"
#include "system_tick.h"
#include "math.h"
//#include "arm_math.h"
int i=0;
float c=1.3f,sin_vlu=0.0f,cos_vlu=0.0f;
int main(void)
{
SystemTick_init();
LED_Init();
while(1)
{
  LED0_ON;
/*************************FPU运算************************/
for(i=0;i<65536;i++)
  {
//  arm_sin_cos_f32(30.0f,&sin_vlu,&cos_vlu);
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
  }
///*************************CPU运算**************************/
// for(i=0;i<65536;i++)
//  {
//    c = cos(1.3f);
//  }
  LED0_OFF;

/*************************FPU运算************************/
for(i=0;i<65536;i++)
  {
//  arm_sin_cos_f32(30.0f,&sin_vlu,&cos_vlu);
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
  }
///*************************CPU运算**************************/
// for(i=0;i<65536;i++)
//  {
//    c = cos(1.3f);
//  }
}
}

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
4条回答
augustedward
2019-07-20 22:37
Taven 发表于 2017-10-25 00:23
这里不就是浮点数的加减乘除么,计算量不一样嘛

你不用FPU时用的是 for(i=0;i<65536;i++)
//  {
//    c = cos(1.3f);
//  }


用FPU时,用的是 c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
      c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f*2.5623f/3.00543f+6.00435f-4.56234f;
   c=3.1f*2.5623f/3.00543f+6

这两种公式都不一样。能放到一起比吗?

一周热门 更多>