jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
This tests localStorage performance against WebSQL. localStorage tests contain JSON stringify/parse methods.
<script>
var small, large, idb, websql, ls;
// data setup
small = 'test';
large = '';
for (var i = 0; i < 10000; i++) large += '1234567890';
// store setup
window.indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;
var request = indexedDB.open("benchmark");
request.onsuccess = function(e) {
var v = "1.0";
idb = e.target.result;
if (v != idb.version) {
var setVrequest = idb.setVersion(v);
setVrequest.onsuccess = function(e) {
var store = idb.createObjectStore("benchmark");
e.target.transaction.oncomplete = function() {
var trans = idb.transaction(["benchmark"], "readwrite");
var store = trans.objectStore("benchmark");
store.add(small, 1);
store.add(large, 2);
};
};
};
};
ls = window.localStorage;
ls.clear();
ls[1] = small;
ls[2] = large;
websql = openDatabase('benchmark', '1.0', '', 1 * 1024 * 1024);
websql.transaction(function(tx) {
tx.executeSql('DROP TABLE IF EXISTS benchmark;');
tx.executeSql('CREATE TABLE benchmark (id, value);');
tx.executeSql('INSERT INTO benchmark (id, value) VALUES (?, ?)', [1, small]);
tx.executeSql('INSERT INTO benchmark (id, value) VALUES (?, ?)', [2, large]);
});
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
localStorage read small data |
| ready |
localStorage read large data |
| ready |
WebSQL read small data |
| ready |
WebSQL read large data |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.