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

(defun t_variant-type ( count fptr / time1 time2 4dubs
                                     varNull varNil varFalse varShort varLong varFlt varDbl varStr varArr )
  ;;-----------------------------
  (setq 4dubs (vlax-make-safearray vlax-vbDouble '(0 . 3)))
  (setq varNull  (vlax-make-variant))
  (setq varNil   (vlax-make-variant nil))
  (setq varFalse (vlax-make-variant :vlax-false))
  (setq varShort (vlax-make-variant 5 vlax-vbInteger))
  (setq varLong  (vlax-make-variant 5 vlax-vbLong))
  (setq varFlt   (vlax-make-variant 5.0 vlax-vbSingle))
  (setq varDbl   (vlax-make-variant 5.0 vlax-vbDouble))
  (setq varStr   (vlax-make-variant "ghost"))
  (setq varArr   (vlax-make-variant 4dubs))
  ;;-----------------------------
  (setq time1 (getvar "MILLISECS"))
  (if (not time1) (setq time1 (getvar "TDUSRTIMER")))
  (if (not time1) (setq time1 0.0))

  (repeat (* count count)
    (variant-type varNull)
    (variant-type varNil)
    (variant-type varFalse)
    (variant-type varShort)
    (variant-type varLong)
    (variant-type varFlt)
    (variant-type varDbl)
    (variant-type varStr)
    (variant-type varArr)
  )

  (setq time2 (getvar "MILLISECS"))
  (if (not time2) (setq time2 (getvar "TDUSRTIMER")))
  (if (not time2) (setq time2 0.0))
  ;;-----------------------------
  (setq bench$seconds (if hasMilliSecs (* 0.001 (- time2 time1)) (* 86400.0 (- time2 time1))))
  (princ (strcat "*      VARIANT-TYPE : " (rtos bench$seconds 2 3) "\n"))
  (if fptr
    (princ (strcat "*      VARIANT-TYPE : " (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_variant-type (* 500 $benchcyclesfactor) nil)
  (setvar "cmdecho" 1)
  (princ)
)
