-
-
Save tzarskyz/9372483 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Benchmark: getValue/setValue | |
// @namespace test | |
// @include http* | |
// @version 1 | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// ==/UserScript== | |
var iters = 40; | |
if (window === top) { | |
console.log('Starting set benchmark ...'); | |
var start = new Date().valueOf(); | |
for (var i = 0; i < iters;) { | |
GM_setValue('i', i++); GM_setValue('i', i++); | |
GM_setValue('i', i++); GM_setValue('i', i++); | |
GM_setValue('i', i++); GM_setValue('i', i++); | |
GM_setValue('i', i++); GM_setValue('i', i++); | |
GM_setValue('i', i++); GM_setValue('i', i++); | |
} | |
var end = new Date().valueOf(); | |
console.log(i, 'set calls took', (end - start)); | |
console.log('Starting get benchmark ...'); | |
var start = new Date().valueOf(); | |
for (var i = 0; i < iters; i+=10) { | |
GM_getValue('i'); GM_getValue('i'); | |
GM_getValue('i'); GM_getValue('i'); | |
GM_getValue('i'); GM_getValue('i'); | |
GM_getValue('i'); GM_getValue('i'); | |
GM_getValue('i'); GM_getValue('i'); | |
} | |
var end = new Date().valueOf(); | |
console.log(i, 'get calls took', (end - start)); | |
console.log('Starting get/set benchmark ...'); | |
var start = new Date().valueOf(); | |
for (var i = 0; i < iters; ) { | |
GM_getValue('i'); GM_setValue('i', i++); | |
GM_getValue('i'); GM_setValue('i', i++); | |
GM_getValue('i'); GM_setValue('i', i++); | |
GM_getValue('i'); GM_setValue('i', i++); | |
GM_getValue('i'); GM_setValue('i', i++); | |
GM_getValue('i'); GM_setValue('i', i++); | |
GM_getValue('i'); GM_setValue('i', i++); | |
GM_getValue('i'); GM_setValue('i', i++); | |
GM_getValue('i'); GM_setValue('i', i++); | |
GM_getValue('i'); GM_setValue('i', i++); | |
} | |
var end = new Date().valueOf(); | |
console.log(i, 'get/set calls took', (end - start)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment