Skip to content

Instantly share code, notes, and snippets.

@rwaldron

rwaldron/1 Secret

Last active August 29, 2015 14:03
Show Gist options
  • Save rwaldron/850590359d298e35bc61 to your computer and use it in GitHub Desktop.
Save rwaldron/850590359d298e35bc61 to your computer and use it in GitHub Desktop.
setInterval(function() {
var t0 = performance.now();
var battery = navigator.battery;
var t1 = performance.now();
console.log((t1 - t0) + " ms");
}, 1000);
Reading the navigator.battery every 1000ms (including the very first read)
--------------------------------------------------------------------------
## Device (ZTE Open, FirefoxOS)
Set 1
0.12207000004127622 ms
0.0305180000141263 ms
0.12207100004889071 ms
0.1525879999389872 ms
0.1525879999389872 ms
0.1525879999389872 ms
0.12207000004127622 ms
0.15258800005540252 ms
0.12207100004889071 ms
0.15258800005540252 ms
0.1220699999248609 ms
0.15258800005540252 ms
0.12207000004127622 ms
0.1220699999248609 ms
0.12207099993247539 ms
Set 2
0.12207100000523496 ms
0.0915530000020226 ms
0.03051699999923585 ms
0.061034999998810235 ms
0.061035000002448214 ms
0.09155299999838462 ms
0.12207000000125845 ms
0.12206999999762047 ms
0.0915530000020226 ms
0.09155200000168406 ms
0.1831060000040452 ms
0.09155200000168406 ms
0.09155299999838462 ms
0.03051699999923585 ms
0.0915530000020226 ms
## Desktop (Firefox 30)
Set 1
1.9732779999030754 ms
0.023067000089213252 ms
0.025926000089384615 ms
0.00924100005067885 ms
0.014413000084459782 ms
0.023920000065118074 ms
0.009518999955616891 ms
0.013391999993473291 ms
0.013206999865360558 ms
0.014273000066168606 ms
0.014967000111937523 ms
0.020646999939344823 ms
0.022532999981194735 ms
0.01673899998422712 ms
0.015598999918438494 ms
Set 2
1.7757449999999153 ms
0.01368800000000192 ms
0.012788999999429507 ms
0.009630000000470318 ms
0.014839000000392844 ms
0.009824000000662636 ms
0.009946000001946231 ms
0.014232000001356937 ms
0.010840000000825967 ms
0.010372000000643311 ms
0.01391200000034587 ms
0.014411000000109198 ms
0.009750999999596388 ms
0.01508099999773549 ms
0.013528999999834923 ms
var data = {};
var value = 1;
Object.defineProperty(data, "prop", {
get: function() {
return value;
}
});
setInterval(function() {
var t0 = performance.now();
var value = data.prop;
var t1 = performance.now();
console.log((t1 - t0) + " ms");
}, 1000);
## Desktop
Set 1
0.01396999999997206 ms
0.007457000001522829 ms
0.004668999998102663 ms
0.010329000000638189 ms
0.007075999999869964 ms
0.006676999999399413 ms
0.009379999999509891 ms
0.007211000000097556 ms
0.007324999998672865 ms
0.0068249999967520125 ms
0.007634000001417007 ms
0.005593000001681503 ms
0.008654999997816049 ms
0.005805000000691507 ms
0.006078999998862855 ms
Set 2
0.014169000000038068 ms
0.007779000000482483 ms
0.006561000001966022 ms
0.006145999999716878 ms
0.00798199999917415 ms
0.00787799999852723 ms
0.007115000000339933 ms
0.007132999999157619 ms
0.007535999999163323 ms
0.0071470000002591405 ms
0.007601000001159264 ms
0.007427000000461703 ms
0.008382999996683793 ms
0.00791400000161957 ms
0.006905999998707557 ms
localStorage.setItem("foo", 1);
setInterval(function() {
var t0 = performance.now();
var value = localStorage.getItem("foo");
var t1 = performance.now();
console.log((t1 - t0) + " ms");
}, 1000);
## Desktop
Set 1
0.04078799999842886 ms
0.03734500000427943 ms
0.03769900000770576 ms
0.044149000001198146 ms
0.04647899999690708 ms
0.03755500000261236 ms
0.04407000000355765 ms
0.04301800000393996 ms
0.036360999998578336 ms
0.03777200000331504 ms
0.03776599999400787 ms
0.04419600000983337 ms
0.04359999999724096 ms
0.047048000000359025 ms
0.037319000002753455 ms
Set 2
0.04043500000034328 ms
0.036978999999519147 ms
0.027670999999827472 ms
0.0418310000004567 ms
0.042340999999396445 ms
0.04031299999951443 ms
0.028583000001162873 ms
0.023190000001704902 ms
0.035744000000704546 ms
0.0434320000003936 ms
0.036371000000144704 ms
0.03627500000038708 ms
0.03536299999723269 ms
0.031277999998565065 ms
0.04405600000245613 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment