TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: ribarm on June 11, 2019, 07:38:36 AM

Title: (entmake) vs (entmakex)
Post by: ribarm on June 11, 2019, 07:38:36 AM
I know this is dumb question, but still I have to ask...

I used to use (entmake) function for creating CAD entities if I didn't need it's output as an 'ename and (entmakex) when I needed to get 'ename and store it in some variable... Now, I haven't never run benchmark with comparison of speed of these two... In my theory (entmake) returns complete DXF list and (entmakex) only 'ename, so I suppose that (entmakex) should be faster... Now if that's the case - I could try to change my style and use (entmakex) wherever I used to use (entmake) - I mean - one single letter is not a big deal - the code could never grow too big from it and I need this specific benchmark in case I run into exhaustive iterations or recursions to make routine as much faster as it could be... I know that this is maybe little unusual - I mean both functions exist and should be used appropriately, but I am curious and would have to know is it good to make this small change in style of coding or I am exaggerating too much...

Thanks for you opinion...
Title: Re: (entmake) vs (entmakex)
Post by: ribarm on June 11, 2019, 10:09:33 AM
I think I should stick with (entmake) like I used to... According to my tests, they are equal in timings :

Code: [Select]
(defun c:entm-x-test ( / ti )
  (setq ti (car (_vl-times)))
  (repeat 100000
    (entmake '((0 . "LINE") (10 0.0 0.0 0.0) (11 1.0 1.0 1.0)))
  )
  (prompt "\n(entmake) time : ") (princ (rtos (- (car (_vl-times)) ti) 2 50))
  (setq ti (car (_vl-times)))
  (repeat 100000
    (entmakex '((0 . "LINE") (10 0.0 0.0 0.0) (11 1.0 1.0 1.0)))
  )
  (prompt "\n(entmakex) time : ") (princ (rtos (- (car (_vl-times)) ti) 2 50))
  (princ)
)

(defun c:entx-m-test ( / ti )
  (setq ti (car (_vl-times)))
  (repeat 100000
    (entmakex '((0 . "LINE") (10 0.0 0.0 0.0) (11 1.0 1.0 1.0)))
  )
  (prompt "\n(entmakex) time : ") (princ (rtos (- (car (_vl-times)) ti) 2 50))
  (setq ti (car (_vl-times)))
  (repeat 100000
    (entmake '((0 . "LINE") (10 0.0 0.0 0.0) (11 1.0 1.0 1.0)))
  )
  (prompt "\n(entmake) time : ") (princ (rtos (- (car (_vl-times)) ti) 2 50))
  (princ)
)

;|
Command: ENTM-X-TEST
(entmake) time : 2047.000000000000
(entmakex) time : 2032.000000000000
Command:
Command: ENTX-M-TEST
(entmakex) time : 2203.000000000000
(entmake) time : 2078.000000000000
Command:
Command: ENTM-X-TEST
(entmake) time : 2078.000000000000
(entmakex) time : 2015.000000000000
Command:
Command: ENTX-M-TEST
(entmakex) time : 2016.000000000000
(entmake) time : 2062.000000000000
Command:
Command: ENTM-X-TEST
(entmake) time : 2094.000000000000
(entmakex) time : 2016.000000000000
Command:
Command: ENTX-M-TEST
(entmakex) time : 2328.000000000000
(entmake) time : 2188.000000000000
Command:
Command: (prompt "\nTotal (entmake) : 12547; Total (entmakex) : 12610")
Total (entmake) : 12547; Total (entmakex) : 12610nil
|;