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

34
sim/Test/sim_test.cpp Normal file
View File

@@ -0,0 +1,34 @@
//
// Created by lydxh on 24-9-21.
//
#include <ctime>
#include <cstdio>
#include <syncstream>
#include "sim_test.h"
void Test_RunTime(char *name, void (*pFunction)(void *)) {
clock_t start, end;
double cpu_time_used;
printf("\n------< %s TEST >------\n", name);
start = clock();
pFunction(NULL);
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);
}
void Test_Run(char *name, void (*pFunction)(void *)) {
printf("\n------< %s TEST >------\n", name);
_beginthread(pFunction, 0, NULL);
}

19
sim/Test/sim_test.h Normal file
View File

@@ -0,0 +1,19 @@
//
// Created by lydxh on 24-9-21.
//
#ifndef HW_LIB_SIM_TEST_H
#define HW_LIB_SIM_TEST_H
/**
* @brief 测试函数执行时间
* @param name: [输入] 测试名称
* @param pFunction: [输入] 指向待测试函数的指针
* @return void
* @example Test("FunctionName", functionName);
**/
void Test_RunTime(char *name, void (*pFunction)(void *));
void Test_Run(char *name, void (*pFunction)(void *));
#endif //HW_LIB_SIM_TEST_H