long startTime = System.nanoTime(); //开始時間
//这里写操作
//消耗時間
long consumingTime = System.nanoTime() - startTime;
System.out.println("操作消耗时间--" + consumingTime + "纳秒");
long startTime = System.nanoTime(); //开始時間
//这里写操作
//消耗時間
long consumingTime = System.nanoTime() - startTime;
System.out.println("操作消耗时间--" + consumingTime + "纳秒");
原文:https://www.cnblogs.com/gjack/p/8182172.html