Plaster
New
List
Login
common-lisp
default
anonymous
2022.09.10 18:16:59
(defparameter *points* (point:random :3d 3333333 1.0 1.0 1.0 )) (defparameter *points3d* (point:random :svec3 3333333 1.0 1.0 1.0 )) (defparameter *pointsO* (point:random :ovec3 3333333 1.0 1.0 1.0 )) (defparameter *result* (make-array 9999999 :element-type 'single-float)) (defparameter *ffi-result* (cffi:foreign-alloc :float :count 9999999)) (defmacro time-nogc (form) `(progn (sb-ext:gc :full t) (time ,form))) (defun pack-test (&optional (points *points*) (result *result*)) (time-nogc (loop :for point :in points :for index :by 3 :do (setf (aref result index) (point:x point) (aref result (+ 1 index)) (point:y point) (aref result (+ 2 index)) (point:z point))))) (defun pack-test-3d (&optional (points *points3d*) (result *result*)) (time-nogc (loop :for point :in points :for index :by 3 :do (setf (aref result index) (3d-vectors:vx point) (aref result (+ 1 index)) (3d-vectors:vy point) (aref result (+ 2 index)) (3d-vectors:vz point))))) (defun pack-test-o (&optional (points *pointso*) (result *result*)) (time-nogc (loop :for point :in points :for index :by 3 :do (setf (aref result index) (origin.vec3:x point) (aref result (+ 1 index)) (origin.vec3:y point) (aref result (+ 2 index)) (origin.vec3:z point))))) (defun pack-test-o-cffi (&optional (points *pointso*) (result *ffi-result*)) (time-nogc (loop :for point :in points :for index :by 3 :do (setf (cffi:mem-aref result :float index) (origin.vec3:x point) (cffi:mem-aref result :float (+ 1 index)) (origin.vec3:y point) (cffi:mem-aref result :float (+ 2 index)) (origin.vec3:z point))))) (defun pack-test-3d-cffi (&optional (points *points3d*) (result *ffi-result*)) (time-nogc (loop :for point :in points :for index :by 3 :do (setf (cffi:mem-aref result :float index) (3d-vectors:vx point) (cffi:mem-aref result :float (+ 1 index)) (3d-vectors:vy point) (cffi:mem-aref result :float (+ 2 index)) (3d-vectors:vz point))))) #| LIFE> (pack-test) Evaluation took: 0.140 seconds of real time 0.140018 seconds of total run time (0.140018 user, 0.000000 system) 100.00% CPU 251,251,761 processor cycles 0 bytes consed NIL LIFE> (pack-test-o) Evaluation took: 0.052 seconds of real time 0.051431 seconds of total run time (0.051431 user, 0.000000 system) 98.08% CPU 92,065,609 processor cycles 0 bytes consed NIL LIFE> (pack-test-3d) Evaluation took: 0.064 seconds of real time 0.064652 seconds of total run time (0.064557 user, 0.000095 system) 101.56% CPU 115,744,204 processor cycles 0 bytes consed NIL LIFE> (pack-test-o-cffi) Evaluation took: 0.092 seconds of real time 0.092457 seconds of total run time (0.076371 user, 0.016086 system) 100.00% CPU 165,882,365 processor cycles 0 bytes consed NIL LIFE> (pack-test-3d-cffi) Evaluation took: 0.096 seconds of real time 0.096845 seconds of total run time (0.096734 user, 0.000111 system) 101.04% CPU 173,781,578 processor cycles 0 bytes consed NIL |#
Raw
Annotate
Repaste
Edit