測試條件:
開發環境:keil4
晶元訊號:stm32f103c8t6
主頻:64mhz
1、測試math_temp1 = squarerootfloat(5.0f);
float squarerootfloat(float number)
long i;
float x, y;
const float f = 1.5f;
x= number * 0.5f;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1); //¿¨âí¿ë
//i = 0x5f375a86 - ( i >> 1); //lomont
y = * ( float * ) &i;
y = y * ( f - ( x * y * y ) ); //1st iteration
y = y * ( f - ( x * y * y ) ); //2nd iteration, this can be removed
return number * y;
含有math_temp1 =squarerootfloat(5.0f);**大小如下:
program size: code=25296 ro-data=1016 rw-data=572zi-data=1564
不含math_temp1 =squarerootfloat(5.0f); **大小如下:
program size:code=24764 ro-data=1012 rw-data=564 zi-data=1052
math_temp1 =squarerootfloat(5.0f);**佔:532byte
2、測試math_temp1 = sqrt(5.0f);//函式庫自帶的開根號函式
含有math_temp1 =sqrt(5.0f);**大小如下:
program size: code=25080 ro-data=1016 rw-data=564zi-data=1052
不含math_temp1 =sqrt(5.0f); **大小如下:
program size:code=24764 ro-data=1012 rw-data=564 zi-data=1052
math_temp1 = sqrt(5.0f);**佔:216byte
3、測試math_temp1 = _sqrt(5.0f);//函式庫自帶的開根號函式
含有math_temp1 =_sqrt(5.0f);**大小如下:
program size: code=25084 ro-data=1012 rw-data=564zi-data=1052
不含math_temp1 =_sqrt(5.0f); **大小如下:
program size:code=24764 ro-data=1012 rw-data=564 zi-data=1052
math_temp1 = _sqrt(5.0f);**佔:220byte
1、 測試math_temp1 =utils_fast_atan2(6.0f, 2.0f);//非查表
floatutils_fast_atan2(float y, float x) else else else else else else else else {
*cos = 0.225 * (*cos * *cos- *cos) + *cos;
含有utils_fast_sincos_better(2.0f,&s,&c);**大小
program size: code=28100 ro-data=1012 rw-data=1608zi-data=1560
不含utils_fast_sincos_better(2.0f,&s,&c);**大小
program size: code=24768 ro-data=1016 rw-data=572zi-data=1052
utils_fast_sincos_better(2.0f,&s,&c);**佔:3332byte
2、測試s = my_sin(2.0f);c = my_cos(2.0f);//匿名飛控
#define one_pi (3.14159265)
#define two_pi (2.0 * 3.14159265)
#define angle_unit (two_pi/10.0)
double mx_sin(double rad)
doublesine;
if(rad < 0)
sine= rad*(1.27323954f + 0.405284735f * rad);
else
sine= rad * (1.27323954f - 0.405284735f * rad);
if(sine < 0)
sine= sine*(-0.225f * (sine + 1) + 1);
else
sine= sine * (0.225f *( sine - 1) + 1);
returnsine;
double my_sin(double rad)
s8flag = 1;
if(rad >= one_pi)
rad-= one_pi;
flag= -1;
returnmx_sin(rad) * flag;
float my_cos(double rad)
s8flag = 1;
rad+= one_pi/2.0;
if(rad >= one_pi)
flag= -1;
rad-= one_pi;
returnmy_sin(rad)*flag;
含有s = my_sin(2.0f);c =my_cos(2.0f);**大小
program size:code=28120 ro-data=1016 rw-data=1608 zi-data=1560
不含s = my_sin(2.0f);c =my_cos(2.0f); **大小
program size:code=24768 ro-data=1016 rw-data=572 zi-data=1052
s = my_sin(2.0f);c =my_cos(2.0f); **佔:3352byte ;
c = -0.4157479
3、測試s = sinf(2.0f);c = cosf(2.0f);//庫函式帶有
含有s = sinf(2.0f);c =cosf(2.0f);**大小
program size: code=26292 ro-data=1044 rw-data=572zi-data=1052
不含s = sinf(2.0f);c =cosf(2.0f); **大小
program size: code=24768 ro-data=1016 rw-data=572zi-data=1052
s = sinf(2.0f);c = cosf(2.0f);**佔:1524byte ;
c = -0.4161468
珠心算測試 演算法競賽
時間限制 c c 1秒,其他語言2秒 空間限制 c c 262144k,其他語言524288k 64bit io format lld 題目描述 珠心算是一種通過在腦中模擬算盤變化來完成快速運算的一種計算技術。珠心算訓練,既能夠開發智力,又能夠為日常生活帶來很多便利,因而在很多學校得到普及。某學校的...
LOG演算法對比測試
對比了幾種log演算法,函式double in double x 效果最好。會根據數值大小動態調整運算方法。實測和windodws計算器的結果相當。而且運算效率也不錯。最後有簡單對比測試結果。include includeint csum 0 double coef int n define par...
JWT演算法對比測試
專案在解決臨時許可權的問題,欲引入jwt,故評估對比jwt實現方式之一jws rfc文件 的相關簽名演算法 由jwa規定 指導簽名演算法選擇。測試環境 作業系統 mac os 記憶體 8gb cpu core 2 本地測試只做效能縱向對比,具體耗時取決於具體執行環境 測試結果 演算法迴圈次數 總耗時...