StopWatch stopWatch = new StopWatch("接口花费时间测试");
stopWatch.start("数据库查询");
//查询数据库
stopWatch.stop();
stopWatch.start("数据组装");
//数据组装
stopWatch.stop();
log.info(stopWatch.prettyPrint());
计算接口在那部分耗时最久,非常有用,不用频繁的使用
System.currentTimeMillis()
然后再减去之前的时间