JSON Parsing Performance (v7)

Revision 7 of this benchmark created on


Description

Testing DataStorage.js performance increases for repeatedly accessing Objects in localStorage.

datastorage.js

Preparation HTML

<script src="https://raw.github.com/marcneuwirth/datastorage.js/master/dataStorage.js"></script>

Setup

localStorage = localStorage || {};
    var storageArray = {};
    var small = {
      "main": "MAIN",
      "skip_scan": "SKIP_SCAN",
      "cmpnt_ver": "CMPNT_VER",
      "scan_manual_scanning": "SCAN_MANUAL",
      "scan_manual_target": "SCAN_MANUAL",
      "update": "UPDATE",
      "logs": "LOGS",
      "settings": "SETTINGS",
      "tools": "TOOLS",
      "threat_details": "THREAT_DETAILS",
      "popup_chk_pwd_shutdown": "POPUP_CHK_PWD_SHUTDOWN",
      "popup_chk_pwd_unlock": "POPUP_CHK_PWD_UNLOCK",
      "popup_bm_ask": "POPUP_BM_ASK",
      "popup_rt_detect_result_info": "POPUP_RT_DETECT_RESULT_INFO",
      "popup_wifi": "POPUP_WIFI",
      "popup_fa_restore": "POPUP_FA_RESTORE",
      "popup_restart_xxx": "POPUP_RESTART_XXX",
      "popup_shutdown_pc": "POPUP_SHUTDOWN_PC",
      "popup_restart_driver": "POPUP_RESTART_DRIVER",
      "popup_chk_scan": "POPUP_CHK_SCAN",
      "popup_usb_encrypt_pwd": "POPUP_USB_ENCRYPT_PWD",
      "*": "ID_UIPOPUP_update.html => shold be replaced by 'update'"
    }
    storageArray['small'] = small;
    localStorage['small'] = JSON.stringify(small);
    dataStorage.putData('small', small);

Test runner

Ready to run.

Testing in
TestOps/sec
Small: JSON Parse
if (localStorage['small'] !== undefined) {
  var d = JSON.parse(localStorage['small']);
}
ready
Small: No Parse Lookup
if (storageArray['small'] !== undefined) {
  var d = storageArray['small'];
}
ready
Small: DataStorage
var d = dataStorage.getData('small');
ready
Med: JSON Parse
 
ready
Med: No Parse Lookup
 
ready
Med: DataStorage
 
ready
Large: JSON Parse
 
ready
Large: No Parse Lookup
 
ready
Large: DataStorage
 
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.