在具有i7、queryperformance/frequency和时钟don'的Windows上以C为单位的执行时间;行不通
我需要测量方法运行时经过的时间。我用在具有i7、queryperformance/frequency和时钟don'的Windows上以C为单位的执行时间;行不通,c,windows,query-performance,execution-time,C,Windows,Query Performance,Execution Time,我需要测量方法运行时经过的时间。我用QueryPerformanceCounter尝试了QueryPerformanceFrequency和clock\u t(这两种方法的示例,我从这里类似的问题中得到): 对于clock\t我有: clock_t start, end; start = clock(); method(one, two, result);/***** Method I need timed *****/ end = clock(); double timeElapsed = (
QueryPerformanceCounter
尝试了QueryPerformanceFrequency
和clock\u t
(这两种方法的示例,我从这里类似的问题中得到):
对于clock\t
我有:
clock_t start, end;
start = clock();
method(one, two, result);/***** Method I need timed *****/
end = clock();
double timeElapsed = (double)(end-start) / CLOCKS_PER_SEC;
我有#include
用于时钟
和#include
和#include
用于查询性能频率
和查询性能计数器
。
每次我用这两种方法运行这段代码时,经过的时间都是0。是否有可能代码运行速度太快,无法使用上面使用的方法进行测量,如果是,我可以用什么方法来补救
clock_t start, end;
start = clock();
method(one, two, result);/***** Method I need timed *****/
end = clock();
double timeElapsed = (double)(end-start) / CLOCKS_PER_SEC;