Objects or not Objects

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
objects
var drawBox = function() {
  input = document.getElementById('input').value;
  colour = document.getElementById('colour').value;

  if (document.getElementById('circle').checked === true) {
    drawCircle();
  } else if (document.getElementById('square').checked === true) {
    drawSquare();
  } else if (document.getElementById('rectangle').checked === true) {
    drawRectangle();
  }
}

var drawRectangle = function() {
  width = prompt("What width do you want the rectangle to be");
  height = prompt("What height do you want the rectangle to be");
  document.getElementById('display').style.cssText = "display: block;" + "width: " + width + ";height: " + height + ";border: 1px solid " + colour;
}

var drawSquare = function() {
  document.getElementById('display').style.cssText = "display: block;" + "width: " + input + ";height: " + input + ";border: 1px solid " + colour;
}

var drawCircle = function() {
  document.getElementById('display').style.cssText = "display: block; border-radius: 50%;" + "width: " + input + ";height: " + input + ";border: 1px solid " + colour;
}
ready
Not objects
var drawBox = function() {
  var input = document.getElementById('input').value;
  var colour = document.getElementById('colour').value;

  if (document.getElementById('circle').checked === true) {
    document.getElementById('display').style.cssText = "display: block; border-radius: 50%;" + "width: " + input + ";height: " + input + ";border: 1px solid " + colour;
  } else if (document.getElementById('square').checked === true) {
    document.getElementById('display').style.cssText = "display: block;" + "width: " + input + ";height: " + input + ";border: 1px solid " + colour;
  } else if (document.getElementById('rectangle').checked === true) {
    var width = prompt("What width do you want the rectangle to be");
    var height = prompt("What height do you want the rectangle to be");
    document.getElementById('display').style.cssText = "display: block;" + "width: " + width + ";height: " + height + ";border: 1px solid " + colour;
  }


}
ready

Revisions

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