Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ebidel
Created August 1, 2014 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebidel/d9c591d77b4c2b68c347 to your computer and use it in GitHub Desktop.
Save ebidel/d9c591d77b4c2b68c347 to your computer and use it in GitHub Desktop.
navigator.getBattery() read time
http://jsbin.com/zibaraju/1/edit
<div></div>
<script>
var div = document.querySelector('div');
setInterval(function() {
var t0 = performance.now();
navigator.getBattery().then(function() {
var t1 = performance.now();
div.innerHTML += (t1 - t0) + " ms<br>";
}, function() {
console.log('error');
});
}, 1000);
</script>
Reading the navigator.getBattery() every 1000ms (including the very first read)
--------------------------------------------------------------------------
// Chrome Desktop - 38.0.2109.0 (Official Build 286623) canary
1.9339999998919666 ms
0.5879999953322113 ms
0.5550000350922346 ms
0.2690000110305846 ms
0.23200002033263445 ms
0.7070000283420086 ms
0.3179999766871333 ms
// Chrome Android - 38 dev
3.273999987868592 ms
0.6850000063423067 ms
5.814000003738329 ms
1.564000005600974 ms
0.13800000306218863 ms
0.7790000236127526 ms
0.7120000082068145 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment