Created
April 25, 2012 19:48
-
-
Save swannodette/2492799 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (def a1 (array 1 2 3)) | |
| (def a2 (array 4 5 6)) | |
| (dotimes [_ 5] | |
| (time | |
| (dotimes [_ 1000000] | |
| (let [x1 (aget a1 0) | |
| y1 (aget a1 1) | |
| z1 (aget a1 2) | |
| x2 (aget a2 0) | |
| y2 (aget a2 1) | |
| z2 (aget a2 2)] | |
| (array (+ x1 x2) (+ y1 y2) (+ z1 x2)))))) | |
| (deftype Vec3d [x y z]) | |
| (def v1 (Vec3d. 1 2 3)) | |
| (def v2 (Vec3d. 4 5 6)) | |
| (dotimes [_ 5] | |
| (time | |
| (dotimes [_ 1000000] | |
| (let [x1 (.-x v1) | |
| y1 (.-y v1) | |
| z1 (.-z v1) | |
| x2 (.-x v2) | |
| y2 (.-y v2) | |
| z2 (.-z v2)] | |
| (Vec3d. (+ x1 x2) (+ y1 y2) (+ z1 x2)))))) | |
| ;; Testing with V8 | |
| ;; "Elapsed time: 17 msecs" | |
| ;; "Elapsed time: 11 msecs" | |
| ;; Testing with SpiderMonkey | |
| ;; "Elapsed time: 676 msecs" | |
| ;; "Elapsed time: 1475 msecs" | |
| ;; Testing with JavaScriptCore | |
| ;; "Elapsed time: 108 msecs" | |
| ;; "Elapsed time: 87 msecs" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment