localStorage get/set vs dot notation (v2)

Revision 2 of this benchmark created on


Description

Testing the speed of the getter and setter functions vs dot notation

Setup

target_size = 100;
    current = 0;

Teardown


    current = 0;
  

Test runner

Ready to run.

Testing in
TestOps/sec
getItem null value
for (; current < target_size; current++) {
  localStorage.getItem('test');
}
ready
getItem with value
localStorage.setItem('test', 1);
for (; current < target_size; current++) {
  localStorage.getItem('test');
}
ready
dot notation fetch undefined
for (; current < target_size; current++) {
  localStorage.test;
}
ready
dot notation get value
localStorage.setItem('test', 1);
for (; current < target_size; current++) {
  localStorage.test;
}
ready
setItem
for (; current < target_size; current++) {
  localStorage.setItem('test', 1);
}
ready
dot notation set
for (; current < target_size; current++) {
  localStorage.test = 1;
}
ready
get brackets
localStorage.setItem('test', 1);
for (; current < target_size; current++) {
  localStorage['test'];
}
ready
set brackets
for (; current < target_size; current++) {
  localStorage['test'] = 1;
}
ready

Revisions

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