plain object access vs style declaration access

Benchmark created on


Description

This perf compares the performance of accessing a property on a plain object vs accessing one on a CSSStyleDeclaration.

Setup

var plain = { width: true }
var style = document.createElement('div').style
var existing = 'width'
var notExisting = 'nomnom'

Test runner

Ready to run.

Testing in
TestOps/sec
existing in plain
existing in plain
ready
existing in style
existing in style
ready
notExisting in plain
notExisting in plain
ready
notExisting in style
notExisting in style
ready
plain.hasOwnProperty(existing)
plain.hasOwnProperty(existing)
ready
style.hasOwnProperty(existing)
style.hasOwnProperty(existing)
ready
plain.hasOwnProperty(notExisting)
plain.hasOwnProperty(notExisting)
ready
style.hasOwnProperty(notExisting)
style.hasOwnProperty(notExisting)
ready
plain[existing] === undefined
plain[existing] === undefined
ready
style[existing] === undefined
style[existing] === undefined
ready
plain[notExisting] === undefined
plain[notExisting] === undefined
ready
style[notExisting] === undefined
style[notExisting] === undefined
ready

Revisions

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