// Many developers are unaware how much influence the scope of a variable has
// on script performance.  To demonstrate this, we create the following
// JSLitmus tests to measure how the "increment" operator performs when applied
// to variables defined in different scopes

// First, test a variable in the global scope
var global_var = 1;
JSLitmus.test('global', function(count) {
  while (count--) global_var++;}
);

// Now test one that's in a function's local scope
JSLitmus.test('local', function(count) {
  var local_var = 1;
  while (count--) local_var++;
});

// Try a variable bound to a closure function.  Prototype and JQuery developers
// should find this particularly interesting.
JSLitmus.test('closure',
  (function() {
    var closure_var = 1;
    return function(count) {while (count--) closure_var++;}
  })()
);

// Closure binding again, but this time with the variable bound through nested
// closures.
JSLitmus.test('multi-closure',
  (function() {
    var multi_var = 1;
    return (function() {
      return function(count) {while (count--) multi_var++;}
    })()
  })()
);

// Test an empty function call, which we can use as a reference point
JSLitmus.test('empty function call', function(count) {
  var f = function() {};
  while (count--) f();
});
