OpenMP(3) omp_get_wtime 函数

omp_get_wtime函数可以返回从某个特殊点所经过的时间,单位秒

double omp_get_wtime( );

返回值:返回从任意一个一致点所经过的时间,单位秒。这个时间点在程序运行过程中必须有一致性,这样才能实现后续比较。

例子:

// omp_get_wtime.cpp
// compile with: /openmp
#include "omp.h"
#include 
#include 

int main() {
    double start = omp_get_wtime( );
    Sleep(1000);
    double end = omp_get_wtime( );
    double wtick = omp_get_wtick( );

    printf_s("start = %.16g\nend = %.16g\ndiff = %.16g\n",
             start, end, end - start);

    printf_s("wtick = %.16g\n1/wtick = %.16g\n",
             wtick, 1.0 / wtick);
}

结果
start = 594255.3671159324
end = 594256.3664474116
diff = 0.9993314791936427
wtick = 2.793651148400146e-007
1/wtick = 3579545

原地址
https://msdn.microsoft.com/en-us/library/t3282fe5.aspx

你可能感兴趣的:(高性能运算/并行编程)