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

(defun t_vlax-ldata-test ( count fptr / time1 time2 )

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

  (repeat (* count count)
    (vlax-ldata-test 123)
  )

  (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 "* VLAX-LDATA-TEST : " (rtos bench$seconds 2 3) "\n"))
  (if fptr                                     
    (princ (strcat "* VLAX-LDATA-TEST : " (rtos bench$seconds 2 3) "\n") fptr)
  )
  bench$seconds
)

(princ)

(defun check-vlax-ldata-test ( / ename vlaname ss )

  ;------------------------
  (entmake '((0 . "POINT")(10 0.0 0.0 0.0)))
  (setq ename (entlast))
  (setq vlaname (vlax-ename->vla-object ename))
  (setq ss (ssadd ename))

  (if (/= (vlax-ldata-test nil) t) (logmsg "<nil> failed")(princ))
  (if (/= (vlax-ldata-test t) t) (logmsg "<t> failed")(princ))
  (if (/= (vlax-ldata-test 123) t) (logmsg "<123> failed")(princ))
  (if (/= (vlax-ldata-test 123.456) t) (logmsg "<123.456> failed")(princ))
  (if (/= (vlax-ldata-test "abc") t) (logmsg "<'abc'> failed")(princ))
  (if (/= (vlax-ldata-test '(1 2 3)) t) (logmsg "<(1 2 3)> failed")(princ))
  (if (/= (vlax-ldata-test '(1 2 3 4 5)) t) (logmsg "<(1 2 3 4 5)> failed")(princ))
  (if (/= (vlax-ldata-test '(1.0 2.0 3.0 4.0)) t) (logmsg "<(1.0 2.0 3.0 4.0)> failed")(princ))
  (if (/= (vlax-ldata-test ename) t) (logmsg "<ename> failed")(princ))
  (if (/= (vlax-ldata-test vlaname) t) (logmsg "<vla-ename> failed")(princ))
  (if (/= (vlax-ldata-test ss) nil) (logmsg "<selection-set> failed")(princ))
  (if (/= (vlax-ldata-test (vlax-make-variant)) nil) (logmsg "<variant nil> failed")(princ))
  (if (/= (vlax-ldata-test (vlax-make-variant 5 vlax-vbInteger)) nil) (logmsg "<variant integer> failed")(princ))
  (if (/= (vlax-ldata-test (vlax-make-safearray vlax-vbDouble '(0 . 2))) nil) (logmsg "<safearray> failed")(princ))

  ;;-----------------------
  (entdel ename)

  (princ)
)

;; 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_vlax-ldata-test (* 200 $benchcyclesfactor) nil)
  (setvar "cmdecho" 1)
  (princ)
)
