52 lines
1.2 KiB
C
52 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
#include "t_spi.h"
|
|
#include "t_iic.h"
|
|
#include "t_task.h"
|
|
#include "t_arg.h"
|
|
#include "tool.h"
|
|
#include <time.h>
|
|
|
|
void Test(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("\nTime taken by %s: %f seconds\n", name, cpu_time_used);
|
|
|
|
printf("\n------< %s END >------\n", name);
|
|
}
|
|
|
|
#define END "\n"
|
|
#define TYPE_F(v) _Generic((v), \
|
|
char :"[char]-> "#v"=%c" END, \
|
|
short :"[short]-> "#v"=%d" END, \
|
|
int :"[int]-> "#v"=%d" END, \
|
|
float :"[float]-> "#v"=%.2f" END , \
|
|
double :"[double]-> "#v"=%.2f" END, \
|
|
default: "[err]-> "#v"=%p" END)
|
|
#define POUT(s) printf(TYPE_F(s) ,s)
|
|
|
|
int main() {
|
|
srand((unsigned) time(NULL));
|
|
int i = 1;
|
|
POUT((++i) + (++i));
|
|
|
|
char str[] = "123.456";
|
|
float result = Str2Float(str);
|
|
printf("Result: %.3f\n", result);
|
|
// Test("SPI", Test_spi);
|
|
// Test("IIC", Test_iic);
|
|
// Test("ArgPase", Test_argpase);
|
|
// Test("Task", Test_task);
|
|
return 0;
|
|
}
|