C ++ exact time using various time statistics cited

The method of obtaining time

  1. ctime library

    Second only to statistics
    for algorithm problem: After you let the program run 1000 times the average at the time, a few times or more

    For project code: 1000 times? come on!
    We need to improve accuracy

  2. time library

  3. windows.h: millisecond
    std :: GetTickCount ()

  4. windows.h: subtle level

LARGE_INTEGER tmp;
QueryPerformanceFrequency(&tmp);//QueryPerformanceFrequency()作用:返回硬件支持的高精度计数器的频率。
  1. Linux platform: sys / time.h: milliseconds

    struct timeval time ;

Published 32 original articles · won praise 31 · views 10000 +

Guess you like

Origin blog.csdn.net/TowerOs/article/details/104280482