找出eclipse中指令占用的指令周期数 - Android

时间:2012-02-03 09:18:30

标签: android cycle systemtime machine-instruction processing-instruction

我如何知道典型的wifi扫描在Android设备中占用了多少指令周期?当然它会因设备而异,但有没有办法找到它?我正在使用eclipse。说明是:

         wifiManager.startScan();

其中wifiManager是WifiManager类的一个实例。

我还想知道执行扫描即执行所述指令所花费的时间(以毫秒为单位)。我发现了

         System.currentTimeMillis();

但在开发者网站上提到: “这种方法不应用于测量超时或其他经过时间的测量,因为改变系统时间会影响结果。” 这是什么意思? 任何帮助,将不胜感激。谢谢。

1 个答案:

答案 0 :(得分:0)

这意味着您必须使用System.currentTimeMillis();仅用于您的性能测试。

示例:

long beforeTime = System.currentTimeMillis();

//performance code goes here

long afterTime = System.currentTimeMillis();

System.out.println("Your code was running " + afterTime - beforeTime + "milis"); 
相关问题