C++ 获取函数耗时
生活随笔
收集整理的這篇文章主要介紹了
C++ 获取函数耗时
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
C++ 記錄耗時?
#include <sys/timeb.h> #include <stdio.h>long long getSystemTime() {struct timeb t;ftime(&t);return 1000 * t.time + t.millitm; } {long long startTime = getSystemTime();long long endTime = getSystemTime();long long ticck = (endTime - startTime);__android_log_print(ANDROID_LOG_DEBUG, "wmh", "onSearchStatusChanged S =%llu,E =%llu,ticck = %llu",startTime,endTime,ticck); }
Java 記錄耗時
public class Time {public static void main(String[] args) {try {long startTime = System.currentTimeMillis();Thread.sleep(3000);long endTime = System.currentTimeMillis();System.out.println("time: " + (endTime - startTime) + " ms");} catch (InterruptedException e) {e.printStackTrace();}} }
轉載于:https://www.cnblogs.com/wangmh/p/7598634.html
總結
以上是生活随笔為你收集整理的C++ 获取函数耗时的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Codeforces 864E Fire
- 下一篇: 梦到老公和别的女人好了预示着什么