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

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
entmake/ActiveX race
« on: October 29, 2003, 04:03:49 PM »
Quote from: SMadsen
But inserting the block I would probably do with ENTMAKE. It's fast, it's clean and it can be tested more easily than a command (unless VL-CMDF is used).
Good point. ActiveX is good way too, though probably still a little more code work than entmake. Anybody up for a race?

SMadsen

  • Guest
entmake/ActiveX race
« Reply #1 on: October 29, 2003, 04:51:49 PM »
Do you mean race in CPU speed or in typing?

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
entmake/ActiveX race
« Reply #2 on: October 29, 2003, 05:06:41 PM »
I don't use ENTMAKE any more. I got bit by the e-lock violation bug(?) once and that was enough. So now I create everything using ActiveX. I'm not positive, but I think they have resolved e-lock violation issue in 2004.

Anyone know for sure?
TheSwamp.org  (serving the CAD community since 2003)

SMadsen

  • Guest
entmake/ActiveX race
« Reply #3 on: October 29, 2003, 05:16:35 PM »
After installing 2004 I have not experienced any problems with mixing AutoLISP and ActiveX to modify the database, so yes, own experience and what I've heard all around point to the possibility that they have fixed it.

Of course, I got in the habit not to mix it before due to what you describe, so own experience may not count that much :)

Now we only have to wait until 2010 when 2002 is a bygone, then it should be safe. Then there's only the matter if AutoLISP will still be supported at that time. Oh well. That's life.

daron

  • Guest
entmake/ActiveX race
« Reply #4 on: October 29, 2003, 05:18:36 PM »
I meant entmake vs. ActiveX. Say insert a block named circ, containing a circle drawn at 2in. I think that's 5.08cm for Stig. on layer 0, color white, linetype continuous. Inserted 1000 times. So yes, CPU speed test, like before.

SMadsen

  • Guest
entmake/ActiveX race
« Reply #5 on: October 29, 2003, 05:53:16 PM »
Using the timer from previously threads, I get readings between 3.45 and 3.65 seconds with the functions below.

Within 12 runs (12.000 inserts) it made an average of 3.55 seconds pr. 1000 inserts.

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 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")
)

daron

  • Guest
entmake/ActiveX race
« Reply #6 on: October 29, 2003, 06:42:25 PM »
I'll have to get back to this in the morning. I'll test my function and let you know then. See you tomorrow. BTW Stig, did you register in time to get classes at AU?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
entmake/ActiveX race
« Reply #7 on: October 29, 2003, 08:36:49 PM »
Don't know if i did it right?
But this what i  get.


Code: [Select]
Command: timer
Timed insCircle: 0.079983
Command:
Command: timer
Timed insCircle: 0.080024
Command:
Command: timer
Timed insCircle: 0.090002
Command:
Command: timer
Timed insCircle: 0.079983
Command:
Command: timer
Timed insCircle: 0.079983
Command:
Command: timer
Timed insCircle: 0.090002
Command:
Command: timer
Timed insCircle: 0.090002
Command:
Command: timer
Timed insCircle: 0.090967
Command:
Command: timer
Timed insCircle: 0.090002
Command:
Command: timer
Timed insCircle: 0.080024
Command:
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.

SMadsen

  • Guest
entmake/ActiveX race
« Reply #8 on: October 30, 2003, 06:19:54 AM »
If you created a block called "circ" with the spec's that Daron stated then did it right, CAB.
Thanks for revealing that my pc is really old and slow!  Heh

Of course, a benchmark test is to be tested on the same pc and the same environment. No two different setups give the same readings.
With my pc at work I get 0.75 in average. Still a pc much slower than yours!

daron

  • Guest
entmake/ActiveX race
« Reply #9 on: October 30, 2003, 10:29:27 AM »
Well, here's my version. Stig, Entmake is faster than what I could come up with. I tried mine four times and your's once. Times posted at the bottom. Mark, do you have an ActiveX function that'll outperform mine?
Code: [Select]
(defun c:instest ()
     (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)
     )
     (startTimer)
     (repeat 1000
 (vla-InsertBlock
      (vla-get-modelspace
   (vla-get-activedocument
(vlax-get-acad-object)
   )
      )
      (vlax-3d-point 0 0 0)
      "circ"
      (vlax-make-variant 1.0 vlax-vbDouble)
      (vlax-make-variant 1.0 vlax-vbDouble)
      (vlax-make-variant 1.0 vlax-vbDouble)
      (vlax-make-variant 0.0 vlax-vbDouble)
 )
     )
     (endTimer "instest")
)

1.547004
1.593997
1.594037
1.609004
0.672014 Stig's function

daron

  • Guest
entmake/ActiveX race
« Reply #10 on: October 30, 2003, 10:38:26 AM »
CAB, what are the spec's of your computer. Your times are blazingly fast. I should be getting a new computer soon. My lease is up. WooHoo.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
entmake/ActiveX race
« Reply #11 on: October 30, 2003, 10:39:26 AM »
Quote
Mark, do you have an ActiveX function that'll outperform mine?
I doubt it. Have you tried getting rid of the vlax-make-variant 0.0 vlax-vbDouble and see if it gets any faster?
TheSwamp.org  (serving the CAD community since 2003)

daron

  • Guest
entmake/ActiveX race
« Reply #12 on: October 30, 2003, 10:58:52 AM »
Just tried it. Get's slower with each pass. Restarted computer and retried it. A smidgen quicker, not good.
1.49972

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
entmake/ActiveX race
« Reply #13 on: October 30, 2003, 11:17:57 AM »
Actually my wife's computer is faster than mine but I can't get her to see that I need it more.


No Name Box w/ Asus A7A266 mother board w/ AMD 1.4 ghz 512M ram  G450 graphics card
40G HD 7200rpm  80G HD 7200rpm


Puny 15" CRT, any suggestions??   keep $$$ in mind.


The routine does get slower with each run.

________________________
edit* I think changing here to her clarifies it better.
________________________
CAB
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.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
entmake/ActiveX race
« Reply #14 on: October 30, 2003, 11:22:36 AM »
Quote from: CAB
Actually my wife's computer is faster than mine but I can't get here to see that I need it more.


No Name Box w/ Asus A7A266 mother board w/ AMD 1.4 ghz 512M ram  G450 graphics card
40G HD 7200rpm  80G HD 7200rpm


Puny 15" CRT, any suggestions??   keep $$$ in mind.

CAB, are you buying or selling? Help......i'm lost here :D
TheSwamp.org  (serving the CAD community since 2003)

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.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
entmake/ActiveX race
« Reply #30 on: October 31, 2003, 03:18:08 PM »
Ok, I have a question. If I save this as say instest.dvb and open a new dwg how can I load and run it from the command line?
TheSwamp.org  (serving the CAD community since 2003)

daron

  • Guest
entmake/ActiveX race
« Reply #31 on: October 31, 2003, 03:35:22 PM »
like this: ^C^C-vbarun ProjectName.dvb!ModuleName.SubName I think. I just hit the run button in the vbaide. I don't know if that slowed it down or anything.

You might need to call the function as a sub in the module. I'm not sure. I'm just stumbling through this vba thing and needing to learn as much as possible before December 2nd.

SomeCallMeDave

  • Guest
entmake/ActiveX race
« Reply #32 on: October 31, 2003, 03:54:31 PM »
Yes,  it should be a sub rather than function.

if you save it as a dvb,  use vbaman at the command line to load it. But I would open the vba ide and just paste the code in the ThisDrawing module.

Then F5 to run it.  (or vbarun at the command line)
But do change Public function to public Sub  and change End Function to End Sub.