Question

How can i find out how many instruction cycles does a typical wifi scan take in an android device? Of course it will vary from device to device, but is there a way to find it out? I'm using eclipse. The instruction is:

         wifiManager.startScan();

where wifiManager is an instance of WifiManager class.

I also want to know the time taken in milliseconds to perform the scan i.e. to execute the said instruction. I found it out using

         System.currentTimeMillis();

But on the developers website it is mentioned: "This method shouldn't be used for measuring timeouts or other elapsed time measurements, as changing the system time can affect the results." What does this mean??
Any help would be appreciated. Thank you.

Was it helpful?

Solution

It means that you must use System.currentTimeMillis(); only for your performance tests.

Example:

long beforeTime = System.currentTimeMillis();

//performance code goes here

long afterTime = System.currentTimeMillis();

System.out.println("Your code was running " + afterTime - beforeTime + "milis"); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top