计时代码如下

long begintime = System.currentTimeMillis();

//运算代码

long endtime=System.currentTimeMillis();

long costTime = (endtime - begintime);
long begintime = System.nanoTime();

//运算代码

long endtime = System.nanoTime();
long costTime = (endtime - begintime)/1000;

//要换算为微秒,就除上1000,就可以