with lookup

Benchmark created on


Setup

var obj
    , lib  = { x: 1, y: 2 }
    , lib2 = { x: 1, y: 2, z: 3 }
    , z      = 3
  
    , with1  = function(){
                 with(lib){ return function() {
                   x += y + z }}}()
  
    , with2  = function() {
                 with(lib2){ return function() {
                   x += y + z }}}()
  
    , obj1   = function() {
                 return function() {
                   obj.x += obj.y + z }}()
  
    , obj2   = function() {
                 return function() {
                   obj.x += obj.y + z }}()

  Benchmark.prototype.setup = function() {
    lib  = { x: 1, y: 2 }
    lib2 = { x: 1, y: 2, z: 3 }
    obj  = { x: 1, y: 2, z: 3 }
  };

Test runner

Ready to run.

Testing in
TestOps/sec
with
with1()
ready
no wrapping
obj1()
ready
with (top-level)
with2()
ready
no wrapping (obj-only)
obj2()
ready

Revisions

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