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();
}
}
}