asdfasdfwe

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var data = {};
   
    var setAndGet = function(key, value) {
      if (typeof value === 'undefined') return data[key];
      return data[key] = value;
    }
   
    var setAndGet2 = function(key, value) {
      if (value === undefined) return data[key];
      return data[key] = value;
    }
   
    var setAndGet3 = function(key, value) {
      if (arguments.length === 1) return data[key];
      return data[key] = value;
    }
   
    var set = function(key, value) { return data[key] = value; };
    var get = function(key) { return data[key]; };
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
together
setAndGet('test', 'value')
var t = setAndGet('test')
pending…
seperate
set('test', 'value')
var t = get('test')
pending…
3
setAndGet2('test', 'value')
var t = setAndGet2('test')
pending…
4
setAndGet3('test', 'value')
var t = setAndGet3('test')
pending…

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

Compare results of other browsers

0 comments

Add a comment