long starTime=System.currentTimeMillis(); //要执行的代码,例如批量插入10万条数据 long endTime=System.currentTimeMillis(); long Time=endTime-starTime; System.out.println(Time); 备注:循环多次求平均值更准确