获取时间的开销

  • time (s) => 4ns
  • ftime (ms) => 39ns
  • gettimeofday (us) => 30ns
  • clock_gettime (ns) => 26ns (CLOCK_REALTIME)
  • clock_gettime (ns) => 8ns (CLOCK_REALTIME_COARSE)
  • clock_gettime (ns) => 26ns (CLOCK_MONOTONIC)
  • clock_gettime (ns) => 9ns (CLOCK_MONOTONIC_COARSE)  (相对CLOCK_MONOTONIC不精确)
  • clock_gettime (ns) => 170ns (CLOCK_PROCESS_CPUTIME_ID)
  • clock_gettime (ns) => 154ns (CLOCK_THREAD_CPUTIME_ID)
  • cached_clock (s) => 0ns

你可能感兴趣的:(程序设计)