请教精确计时函数的模块化
我在写排序算法时,想用系统提供的精确计时函数QueryPerformanceFrequency和QueryPerformanceCounter来编写一个精确计算某个函数运行时间的自定义函数。
部分代码如下:
struct MyArgs
{
int *a;
int quantity;
bool isAscending;
};
void BubbleSortAdapter(void *args)
{
struct MyArgs *args = (struct MyArgs *)args;
BubbleSort(args->a, args->quantity, args->isAscending);
}
struct MyArgs args;
args.a = a; ...
TimerFunc(BubbleSortAdapter, &args);