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

(if (and (not vle-entget) (findfile "vle-extension.lsp")) (load "vle-extension.lsp"))

(if vlisp-optimizer (vlisp-optimizer nil))

(defun t_vle_entget_dxf7 ( count fptr / ename elist vlaen time1 time2 time3 time4 time5 time6 )

  ;;--- build data list
  (setq elist '((0 . "TEXT") (8 . "0") (10 0.0 0.0 0.0) (40 . 10.0) (1 . "aaa") (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "Standard") (71 . 0) (72 . 0) (11 0.0 0.0 0.0) (210 0.0 0.0 1.0) (73 . 0)))
  (setq ename (entmakex elist))
  (setq vlaen (vlax-ename->vla-object ename))

  ;;--- now run test : NORMAL
  (setq time1 (getvar "MILLISECS"))
  (if (not time1) (setq time1 (getvar "TDUSRTIMER")))
  (if (not time1) (setq time1 0.0))

  (repeat (* count count)
    (cdr (assoc 7 (entget ename)))
  )

  (setq time2 (getvar "MILLISECS"))
  (if (not time2) (setq time2 (getvar "TDUSRTIMER")))
  (if (not time2) (setq time2 0.0))

  ;;--- now run test : VLA
  (setq time3 (getvar "MILLISECS"))
  (if (not time3) (setq time3 (getvar "TDUSRTIMER")))
  (if (not time3) (setq time3 0.0))

  (repeat (* count count)
    (vla-get-StyleName vlaen)
  )

  (setq time4 (getvar "MILLISECS"))
  (if (not time4) (setq time4 (getvar "TDUSRTIMER")))
  (if (not time4) (setq time4 0.0))

  ;;--- now run test : FAST
  (setq time5 (getvar "MILLISECS"))
  (if (not time5) (setq time5 (getvar "TDUSRTIMER")))
  (if (not time5) (setq time5 0.0))

  (repeat (* count count)
    (vle-entget 7 ename)
  )

  (setq time6 (getvar "MILLISECS"))
  (if (not time6) (setq time6 (getvar "TDUSRTIMER")))
  (if (not time6) (setq time6 0.0))

  ;;--- test results
  (setq bench$secsNorm (if hasMilliSecs (* 0.001 (- time2 time1)) (* 86400.0 (- time2 time1))))
  (setq bench$secsVla  (if hasMilliSecs (* 0.001 (- time4 time3)) (* 86400.0 (- time4 time3))))
  (setq bench$secsFast (if hasMilliSecs (* 0.001 (- time6 time5)) (* 86400.0 (- time6 time5))))
  (setq bench$seconds (+ bench$secsNorm bench$secsVla bench$secsFast))
  ;;-----------------------------
  (entdel ename)
  ;;-----------------------------

  (princ (strcat "* (ENTGET 7): " (rtos bench$secsNorm 2 3) "  VLA-GET-STYLENAME: " (rtos bench$secsVla 2 3) "  VLE-ENTGET 7: " (rtos bench$secsFast 2 3) "\n"))
  (if fptr
    (princ (strcat "* (ENTGET 7): " (rtos bench$secsNorm 2 3) "  VLA-GET-STYLENAME: " (rtos bench$secsVla 2 3) "  VLE-ENTGET 7: " (rtos bench$secsFast 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_vle_entget_dxf7 (* 300 $benchcyclesfactor) nil)
  (setvar "cmdecho" 1)
  (princ)
)
