Snakes - collision detection

JavaScript performance comparison

Test case created by Jake Gordon

Preparation code

<script>
    var size = 64*64, list = null;
    for(var n = 0 ; n < size ; n++)
     list = { x: size-n, y: size-n, next: list }
    
    function check(x, y, head) {
      var segment = head;
      while (segment = segment.next) {
        if ((x == segment.x) && (y == segment.y))
          return true;
      }
      return false
    }
    
</script>
    

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
1. match early
check(100,100,list)
pending…
2. match middle
check(size/2,size/2,list)
pending…
3. match late
check(size-100,size-100,list)
pending…
4. no match
check(42,99,list)
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