Author Topic: entmake/ActiveX race  (Read 19671 times)

0 Members and 1 Guest are viewing this topic.

SMadsen

  • Guest
entmake/ActiveX race
« Reply #15 on: October 30, 2003, 11:32:18 AM »
Daron, changed your function so that it works with ready-built values, and moved the timer functions outside so that function calls are the same (outside the stack):

Code: [Select]
(defun startTimer () (setq time (getvar "DATE")))

(defun endTimer (func)
  (setq time    (- (getvar "DATE") time)
        seconds (* 86400.0 (- time (fix time)))
  )
  (gc)
  (outPut seconds func)
)

(defun outPut (secs def)
  (gc)
  (princ (strcat "\nTimed " def ": " (rtos secs 2 6)))
  (princ)
)
(defun instest (/ ms ins)
  (setq ms  (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
        ins (vlax-3d-point 0.0 0.0 0.0)
  )
  (startTimer)
  (repeat 1000
    (vla-InsertBlock
      ms ins "circ" 1.0 1.0 1.0 0.0)
  )
  (endTimer "instest")
)


With this, I get an average of 1.29 (a few runs in fresh drawings). The entmake equivalent runs an average of 0.80 here (again, few runs in fresh drawings).
That's a 60% difference, more or less.

daron

  • Guest
entmake/ActiveX race
« Reply #16 on: October 30, 2003, 12:11:40 PM »
Thank you Stig. I can't believe the difference adding variables makes. I would've thought adding variables would slow things down.  Here's the last run using my Stig-modified function.
0.984988

I am using 2004. It seems to be slower than 2002, but all were tested off my machine in 2004.

SMadsen

  • Guest
entmake/ActiveX race
« Reply #17 on: October 30, 2003, 12:43:05 PM »
Quote from: Daron
I would've thought adding variables would slow things down.

You mean getting dressed, starting the car, driving to the grocery, finding a free parking slot, locate a bag of salt on the shelves, standing in line until it's your turn to pay, starting the car, driving home, opening the bag of salt and filling the shaker would be faster than reaching out and grab a readily filled salt shaker on the kitchen table top? :D

daron

  • Guest
entmake/ActiveX race
« Reply #18 on: October 30, 2003, 12:52:17 PM »
Thanks for the visual Stig. So, settings variables invariably speeds things up, huh? Man, I still have so much to learn.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
entmake/ActiveX race
« Reply #19 on: October 30, 2003, 06:11:50 PM »
Hey that's even faster :)


Quote
Command: TIMER
Timed instest: 0.361012
Command:
Command: TIMER
Timed instest: 0.380002
Command:
Command: TIMER
Timed instest: 0.401004
Command:
Command: TIMER
Timed instest: 0.419994
Command:
Command: TIMER
Timed instest: 0.421000
Command:
Command: TIMER
Timed instest: 0.399998
Command:
Command: TIMER
Timed instest: 0.410981
Command:
Command: TIMER
Timed instest: 0.431018
Command:
Command: TIMER
Timed instest: 0.440030
Command:
Command: TIMER
Timed instest: 0.460991
Command:
Command: TIMER
Timed instest: 0.470003
Command:
Command: TIMER
Timed instest: 0.480987
Command:
Command: TIMER
Timed instest: 0.501023
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

daron

  • Guest
entmake/ActiveX race
« Reply #20 on: October 30, 2003, 06:19:31 PM »
That is far quicker, but man that entmake runs circles (no pun intended) around ActiveX.

SMadsen

  • Guest
entmake/ActiveX race
« Reply #21 on: October 30, 2003, 06:23:46 PM »
CAB, makes me feel better to see that a pc way way superior to mine also shows signs of slowing down eventually :)  Thanks!

SMadsen

  • Guest
entmake/ActiveX race
« Reply #22 on: October 30, 2003, 06:27:39 PM »
Heh  nice choice of words
How about trying AddInsert in its native environment, VBA, and compare it to ENTMAKE in it's native environment?
ActiveX is still just an interface to AutoLISP. It's glue, not core.

daron

  • Guest
entmake/ActiveX race
« Reply #23 on: October 30, 2003, 11:52:32 PM »
That's a good idea. I'll have to try and create this function in vba. It may not be pretty, but I'll give it a shot. Maybe I can get some help writing it from the veebeeaye forum if I need it, or maybe they can help me improve it when I get it as far as I can.

ronjonp

  • Needs a day job
  • Posts: 7527
entmake/ActiveX race
« Reply #24 on: October 31, 2003, 09:57:16 AM »
Here is Stigs results on my computer:

Timed instest: 7.889999

Here is Daron's results on my computer:

Timed instest: 8.170988

Good? Bad?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

SMadsen

  • Guest
entmake/ActiveX race
« Reply #25 on: October 31, 2003, 10:06:34 AM »
I think you tested only one function?

^Is why the EndTimer function ends with an identifier string.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
entmake/ActiveX race
« Reply #26 on: October 31, 2003, 10:28:18 AM »
I tried one more function, vlax-invoke-method and the results......

One dwg, each one ran once.
Quote
Command: (instest1)
Timed instest1: 0.484970
Command: (instest2)
Timed instest2: 0.749986
Command: (inscircle)
Timed insCircle: 0.312008


Code: [Select]
;; Darons modified by Stig
(defun startTimer () (setq time (getvar "DATE")))

(defun endTimer (func)
  (setq time       (- (getvar "DATE") time)
        seconds (* 86400.0 (- time (fix time)))
        )
  (gc)
  (outPut seconds func)
  )

(defun outPut (secs def)
  (gc)
  (princ (strcat "\nTimed " def ": " (rtos secs 2 6)))
  (princ)
  )
(defun instest1 (/ ms ins)
  (setq ms  (vla-get-modelspace
              (vla-get-activedocument (vlax-get-acad-object))
              )
        ins (vlax-3d-point 0.0 0.0 0.0)
        )
  (startTimer)
  (repeat 1000
    (vla-InsertBlock ms ins "circ" 1.0 1.0 1.0 0.0)
    )
  (endTimer "instest1")
  )


;; Stigs
(defun insCircle (/ bname)
  (setq bname "circ")
  (startTimer)
  (repeat 1000
    (entmake (list '(0 . "INSERT")
                   '(100 . "AcDbEntity")
                   '(100 . "AcDbBlockReference")
                   (cons 2 "circ")
                   (cons 8 "0")
                   '(10 0.0 0.0 0.0)
             )
    )
  )
  (endTimer "insCircle")
)

;; Darons modified by Stig modified by Mark
(defun instest2 (/ ms ins)
  (setq ms  (vla-get-modelspace
              (vla-get-activedocument (vlax-get-acad-object))
              )
        ins (vlax-3d-point 0.0 0.0 0.0)
        )
  (startTimer)
  (repeat 1000
          (vl-catch-all-apply
            '(vlax-invoke-method ms 'InsertBlock ins "circ" 1.0 1.0 1.0 0.0)
            )
          )
  (endTimer "instest2")
  )
TheSwamp.org  (serving the CAD community since 2003)

daron

  • Guest
entmake/ActiveX race
« Reply #27 on: October 31, 2003, 10:48:49 AM »
So, the moral of this story is:
Entmake - tried and true for lisp.
ActiveX - go glue. We'll see how the core does soon enough. Working on the vba timer function. Currently, it runs faster than anything else I've tried.
vlax - don't invoke method.

SMadsen

  • Guest
entmake/ActiveX race
« Reply #28 on: October 31, 2003, 10:56:25 AM »
Cool

daron

  • Guest
entmake/ActiveX race
« Reply #29 on: October 31, 2003, 03:03:21 PM »
Here's the vba version. SCMDave helped and finished it up.
Code: [Select]
Public Function InsertTest()
  Dim i As Integer
  Dim StartTime As Variant
  Dim EndTime As Variant
 
  Dim lngStart As Long
  Dim lngEnd As Long
  Dim InsPt(0 To 2) As Double
  Dim mspace As AcadModelSpace
  Set mspace = ThisDrawing.ModelSpace
 
  StartTime = ThisDrawing.GetVariable("DATE")
 
  'lngStart = GetTickCount

  For i = 1 To 1000
    mspace.InsertBlock InsPt, "Circ", 1, 1, 1, 0
  Next i
  EndTime = ThisDrawing.GetVariable("DATE")
 
  'lngEnd = GetTickCount
  MsgBox "Total Time = " & CStr((EndTime - StartTime) * 86400)

End Function

My time came in at almost one second. All testers, put it in a module and run it and record your times here. Thanks.