使用i7在Windows上执行C时的执行时间,queryperformace / frequency和clock不起作用

时间:2017-03-11 02:48:03

标签: c windows query-performance execution-time

我需要测量运行方法时经过的时间。我已经尝试QueryPerformanceFrequencyQueryPerformanceCounter以及使用clock_t(两者的例子,我从这里得到的类似问题):

LARGE_INTEGER frequency;
LARGE_INTEGER start;
LARGE_INTEGER end;
double interval;
QueryPerformanceFrequency(&frequency);
QueryPerformanceCounter(&start);
method(one, two, result);/***** Method I need timed *****/
QueryPerformanceCounter(&end);
interval = (double) (end.QuadPart - start.QuadPart) / frequency.QuadPart;

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 <time.h> clock_t#include <windows.h>#include <stdlib.h> QueryPerformanceFrequency QueryPerformanceCounter import shutil Import os source='/dev/sdc /mnt/mnttensor/Dhole/' destination='/home/ubuntu/classificator/nodhole/' fo = open("dhole3.txt", "r") content = fo.readlines() for files in content: shutil.move(source+files,destination+files) 。 每当我用任何一种方法运行这段代码时,我都会在时间过去时得到0。是否有可能代码运行得太快而无法使用上面使用的方法进行测量,如果是这样,我可以采取哪种方法来解决这个问题?

0 个答案:

没有答案