poser perf test attempt

Benchmark created by TheSisb on


Description

Testing poser perf

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Setup

var d = global.document;
    
    function poser(type) {
      var iframe = d.createElement('iframe');
    
      iframe.style.display = 'none';
      d.body.appendChild(iframe);
    
      return map(type, iframe.contentWindow);
    }
    
    function map(type, source) { // forward polyfills to the stolen reference!
      var original = window[type].prototype;
      var value = source[type];
      var prop;
    
      for (prop in original) {
        value.prototype[prop] = original[prop];
      }
    
      return value;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
poser speed
var Array2 = poser('Array');

Array2.prototype.eat = function() {
  var r = this[0];
  delete this[0];
  console.log('Y U NO .shift()?');
  return r;
};

var a = new Array2(3, 5, 7);

a.eat();
// <- 3

console.log(Object.prototype.toString.call(a));
// <- [object Array]
ready
normal extending speed
Array.prototype.eat = function() {
  var r = this[0];
  delete this[0];
  console.log('Y U NO .shift()?');
  return r;
};

var a = new Array(3, 5, 7);

a.eat();
// <- 3

console.log(Object.prototype.toString.call(a));
// <- [object Array]
ready

Revisions

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

  • Revision 1: published by TheSisb on