This commit is contained in:
JiXieShi
2024-09-21 16:07:31 +08:00
parent 4e53f936d8
commit d2e5789476
27 changed files with 129 additions and 67 deletions

View File

@@ -134,14 +134,6 @@ float Str2Float(char *str);
printf(fmt " ", arr[i]); }\
printf("\n"); } while (0)
/**
* @brief 测试函数执行时间
* @param name: [输入] 测试名称
* @param pFunction: [输入] 指向待测试函数的指针
* @return void
* @example Test("FunctionName", functionName);
**/
void Test_RunTime(char *name, void (*pFunction)());
#define END "\n"
#define TYPE_F(v) _Generic((v), \

View File

@@ -5,6 +5,7 @@
#include <ctime>
#include <stdint.h>
#include <cstdlib>
#include <syncstream>
#include "tool.h"
float Mapping(float val, float I_Min, float I_Max, float O_Min, float O_Max) {
@@ -74,20 +75,3 @@ float Str2Float(char *str) {
decimal /= decimalWeight;
return float(sign * (integer + decimal));
}
void Test_RunTime(char *name, void (*pFunction)()) {
clock_t start, end;
double cpu_time_used;
printf("\n------< %s TEST >------\n", name);
start = clock();
pFunction();
end = clock();
cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
printf("\n------< %s END >------\n", name);
printf("\nTime taken by %s: %f seconds\n", name, cpu_time_used);
}