![](/img/trans.png)
[英]How to measure the ACTUAL execution time of a C program under Linux?
[英]What linux api I can use to measure execution time of some functions in my program?
我正在Linux上的C中開發用戶端應用程序。 我可以使用什么Linux API來衡量程序中某些功能的執行時間? 我希望精度達到納秒。
我有谷歌,我發現時鍾點擊的例子。 我需要毫微秒的結果。
謝謝。
您可以使用time.h庫獲取開始時間和結束時間並獲得差值! 但是,這不是Linux特有的!
man clock_gettime
struct timespec以納秒為單位。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.