(setq hasMilliSecs (/= (getvar "MILLISECS") nil))
(setvar "LOGFILEMODE" 0)
(vl-load-com)

(defun t_vla_getboundingbox ( count fptr / time1 time2 app dwg en1 en2 vlaen1 vlaen2 pMin pMax )
  ;;-----------------------------
  (setq app (vlax-get-acad-object))
  (setq dwg (vla-get-activedocument app))

  (setq en1 (entmakex '((0 . "CIRCLE") (10 0 0 0) (40 . 3.5))))
  (setq en2 (entmakex '((0 . "LINE")   (10 0 0 0) (11 10 10 10))))
  (setq vlaen1 (vlax-ename->vla-object en1))
  (setq vlaen2 (vlax-ename->vla-object en2))
  (command "_regen")

  ;;-----------------------------
  (setq time1 (getvar "MILLISECS"))
  (if (not time1) (setq time1 (getvar "TDUSRTIMER")))
  (if (not time1) (setq time1 0.0))

  (repeat (* count count)
    (vla-GetBoundingBox vlaen1 'pMin 'pMax )
    (vla-GetBoundingBox vlaen2 'pMin 'pMax )
  )

  (setq time2 (getvar "MILLISECS"))
  (if (not time2) (setq time2 (getvar "TDUSRTIMER")))
  (if (not time2) (setq time2 0.0))
  ;;-----------------------------
  (entdel en1)
  (entdel en2)

  (setq bench$seconds (if hasMilliSecs (* 0.001 (- time2 time1)) (* 86400.0 (- time2 time1))))
  (princ (strcat "* VLA-GETBOUNDINGBOX : " (rtos bench$seconds 2 3) "\n"))
  (if fptr
    (princ (strcat "* VLA-GETBOUNDINGBOX : " (rtos bench$seconds 2 3) "\n") fptr)
  )
  bench$seconds
)

;; to increase/decrease the number of bench loops : > 1 increase < 1 decrease
(if (not $benchcyclesfactor) (setq $benchcyclesfactor 1))

;; to run this loaded test manually
(defun C:Run ()
  (setvar "cmdecho" 0)
  (print)
  (t_vla_getboundingbox (* 300 $benchcyclesfactor) nil)
  (setvar "cmdecho" 1)
  (princ)
)
