(vl-load-com)
(setvar "LOGFILEMODE" 0)


(defun t_nested_1 ( / arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 )
  (t_nested_2)
)
(defun t_nested_2 ( / arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 )
  (t_nested_3)
)
(defun t_nested_3 ( / arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 )
  (t_nested_4)
)
(defun t_nested_4 ( / arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 )
  (t_nested_5)
)
(defun t_nested_5 ( / arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 )
  (t_nested_6)
)
(defun t_nested_6 ( / arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 )
  (t_nested_7)
)
(defun t_nested_7 ( / arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 )
  (t_nested_8)
)
(defun t_nested_8 ( / arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 )
  (t_nested_9)
)
(defun t_nested_9 ( / arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 )
  (t_nested_10)
)
(defun t_nested_10 ( / arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 )
  nil
)

(defun t_deepnestedcalls ( count fptr / time1 time2 lst )

  ;;-----------------------------
  (setq time1 (getvar "TDUSRTIMER"))

  (repeat (* count count)
    (t_nested_1)
  )

  (setq time2 (getvar "TDUSRTIMER"))
  (if (not time1) (setq time1 0.0))
  (if (not time2) (setq time2 0.0))
  ;;-----------------------------
  (setq bench$seconds (* 86400.0 (- time2 time1)))
  (princ (strcat "* NESTED Calls (10 levels) : " (rtos bench$seconds 2 3) "\n"))
  (if fptr
    (princ (strcat "* NESTED Calls (10 levels) : " (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_deepnestedcalls (* 250 $benchcyclesfactor) nil)
  (setvar "cmdecho" 1)
  (princ)
)
