var test

Benchmark created on


Preparation HTML

<script>
  var rect = [1, 2, 3, 4];
  var thi = [0, 0, 100, 100];
  
  function contains(pt) {
   return (pt[0] >= thi[0] && pt[0] <= thi[0] + thi[2] && pt[1] >= thi[1] && pt[1] <= thi[1] + thi[3]);
  }
  
  function fn1(rect) {
   return (contains(rect[0], rect[1]) && contains(rect[0] + rect[2], rect[1]) && contains(rect[0] + rect[2], rect[1] + rect[3]) && contains(rect[0], rect[1] + rect[3]));
  }
  
  function fn2(rect) {
   var right = rect[0] + rect[2],
       bot = rect[1] + rect[3];
   return (contains(rect[0], rect[1]) && contains(right, rect[1]) && contains(right, bot) && contains(rect[0], bot));
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
fn1
fn1([2, 3, 4, 5]);
ready
fn2
fn1([3, 2, 5, 4]);
ready

Revisions

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