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(); } } }
posted on 2017-09-26 20:07 kenny.wmh 阅读(2250) 评论(0) 编辑 收藏 举报