# nano_stopwatch **Repository Path**: tiger_git/nano_stopwatch ## Basic Information - **Project Name**: nano_stopwatch - **Description**: 一个header only的纳秒精度的计时器,可用于性能分析,支持Windows和Linux。 - **Primary Language**: C - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-11-04 - **Last Updated**: 2023-06-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # nano_stopwatch 一个纳秒精度的计时器,支持Windows和Linux。 ## 示例 ```c #include #include "nano_stopwatch.h" int main() { nsw_t nsw = nsw_init(); printf("elapsed ns: %.2f\n", nsw_elapsed_ns(&nsw)); printf("cpu_cycle = %f\n", __nano_stopwatch_cpu_freq_per_ns); #ifdef _WIN32 Sleep(1000); #else usleep(1000000); #endif // _WIN32 printf("elapsed us: %.2f\n", nsw_elapsed_us(&nsw)); return 0; } 输出: elapsed ns: 20.56 cpu_cycle = 3.696000 elapsed us: 1013685.23 ```