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

(defun t_vlax-safearray-put-element ( count fptr / time1 time2 dblarr matrix )
  ;;-----------------------------
  (setq dblarr (vlax-make-safearray vlax-vbDouble '(1 . 4) ))
  (setq matrix (vlax-make-safearray vlax-vbString '(1 . 2) '(1 . 2) ))
  ;;-----------------------------
  (setq time1 (getvar "MILLISECS"))
  (if (not time1) (setq time1 (getvar "TDUSRTIMER")))
  (if (not time1) (setq time1 0.0))
 
  (repeat (* count count)
      (vlax-safearray-put-element dblarr 1 10.0)
      (vlax-safearray-put-element dblarr 2 11.0)
      (vlax-safearray-put-element dblarr 3 12.0)
      (vlax-safearray-put-element dblarr 4 13.0)
      (vlax-safearray-put-element matrix 1 1 "a")
      (vlax-safearray-put-element matrix 1 2 "b")
      (vlax-safearray-put-element matrix 2 1 "c")
      (vlax-safearray-put-element matrix 2 2 "d")
  )

  (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-SAFEARRAY-PUT-ELEMENT : " (rtos bench$seconds 2 3) "\n"))
  (if fptr
    (princ (strcat "* VLAX-SAFEARRAY-PUT-ELEMENT : " (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_vlax-safearray-put-element (* 300 $benchcyclesfactor) nil)
  (setvar "cmdecho" 1)
  (princ)
)
