Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defparameter v1 '(1 2 3 4))
- (defparameter v2 (vector 1 2 3 4))
- (declaim (inline xywh-to-points1))
- (defun xywh-to-points1 (xywh)
- (let ((x (first xywh))
- (y (second xywh))
- (w (third xywh))
- (h (fourth xywh)))
- `(,x ,y ,(+ x w) ,y ,(+ x w) ,(+ y h) ,x ,(+ y h))))
- (declaim (inline xywh-to-points2))
- (defun xywh-to-points2 (xywh)
- (let ((x (aref xywh 0))
- (y (aref xywh 1))
- (w (aref xywh 2))
- (h (aref xywh 3)))
- `(,x ,y ,(+ x w) ,y ,(+ x w) ,(+ y h) ,x ,(+ y h))))
- (defun test1 ()
- (declare (optimize (speed 3) (safety 0) (debug 0)))
- (loop for j below 100 do
- (loop for i below 10000000 do
- (xywh-to-points1 v1))))
- (defun test2 ()
- (declare (optimize (speed 3) (safety 0) (debug 0)))
- (loop for j below 100 do
- (loop for i below 10000000 do
- (xywh-to-points2 v2))))
- (time (test1))
- (time (test2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement