Advertisement
Guest User

Untitled

a guest
Sep 25th, 2022
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.92 KB | Source Code | 0 0
  1. (defparameter v1 '(1 2 3 4))
  2. (defparameter v2 (vector 1 2 3 4))
  3.  
  4. (declaim (inline xywh-to-points1))
  5. (defun xywh-to-points1 (xywh)
  6.   (let ((x (first xywh))
  7.         (y (second xywh))
  8.         (w (third xywh))
  9.         (h (fourth xywh)))
  10.     `(,x ,y ,(+ x w) ,y ,(+ x w) ,(+ y h) ,x ,(+ y h))))
  11.  
  12. (declaim (inline xywh-to-points2))
  13. (defun xywh-to-points2 (xywh)
  14.   (let ((x (aref xywh 0))
  15.         (y (aref xywh 1))
  16.         (w (aref xywh 2))
  17.         (h (aref xywh 3)))
  18.     `(,x ,y ,(+ x w) ,y ,(+ x w) ,(+ y h) ,x ,(+ y h))))
  19.  
  20. (defun test1 ()
  21.   (declare (optimize (speed 3) (safety 0) (debug 0)))
  22.   (loop for j below 100 do
  23.           (loop for i below 10000000 do
  24.                   (xywh-to-points1 v1))))
  25.  
  26. (defun test2 ()
  27.   (declare (optimize (speed 3) (safety 0) (debug 0)))
  28.   (loop for j below 100 do
  29.           (loop for i below 10000000 do
  30.                   (xywh-to-points2 v2))))
  31. (time (test1))
  32. (time (test2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement