Created
September 22, 2011 03:17
-
-
Save BrianGenisio/1233935 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function math_dist(mmx:int, mmy:int, ox:int, oy:int):Number{ | |
return Math.sqrt((mmx-ox)*(mmx-ox)+(mmy-oy)*(mmy-oy)); | |
} | |
private function point_dist(p1:Point, p2:Point):Number{ | |
return Point.distance( p1, p2 ); | |
} | |
private function time_it():void { | |
var count:int = 100000; | |
var value:Number; | |
var start:Date = new Date(); | |
for(var i = 0; i < count; i++) { | |
value = math_dist(8, 10, 12, 14); | |
} | |
var end:Date = new Date(); | |
mathTime = end.time - start.time; | |
start = new Date(); | |
var p1:Point = new Point(); | |
var p2:Point = new Point(); | |
for(var i = 0; i < count; i++) { | |
p1.x = 8; | |
p1.y = 10; | |
p2.x = 12; | |
p2.y = 14; | |
value = point_dist(p1, p2); | |
} | |
end = new Date(); | |
pointTime = end.time - start.time; | |
} | |
// mathTime = 42 (debug) 4 (release) | |
// pointTime = 121 (debug) 27 (release) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment