Author Topic: woohoo, 2nd topic. Speed testing.  (Read 14455 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
woohoo, 2nd topic. Speed testing.
« on: October 31, 2003, 02:21:08 AM »
Over in the Vlisp Hackers forum, we're having a test on whether entmake is faster than ActiveX (as if you didn't know). Anyway, Stig suggested that I take the ActiveX function and convert it to vba and see if it is any faster. Well, I've done all the converting that I can and need your guys' help. I'll post the module. Will you guys help me finish it up. There are a few things that I can't quite get, like how to get an insertion point working and a few of the timer items. Thanks.
Code: [Select]
Option Explicit
Function starttimer()
Dim time As Long
time = ThisDrawing.GetVariable("date")
End Function

Function endtimer(func)
Dim time As Long
Dim seconds As Long
time = ThisDrawing.GetVariable("date" - time)
seconds = (time - time * 86400#)
output seconds func
End Function

Function output()
msgbox ("Timed result: ",vbokonly)
End Function

Sub instest()
Dim inspt(0 To 2) As Variant
Dim count As Integer
Dim bname As String
Dim blkref As AcadBlockReference
Set inspt = ThisDrawing.Utility.GetPoint(0)
Set blkref = ThisDrawing.ModelSpace.InsertBlock _
            (inspt, "circ", 1#, 1#, 1#, 0)
starttimer
For count = 1 To 1000
    blkref
Next count
endtimer
End Sub

hendie

  • Guest
woohoo, 2nd topic. Speed testing.
« Reply #1 on: October 31, 2003, 04:56:58 AM »
oh it's Friday, and I'm back but we only work until 1pm on a Friday. SO I'll do what I can in the meantime...

Code: [Select]

Dim inspnt As Variant
Me.Hide
inspnt = ThisDrawing.Utility.GetPoint(, "Enter a point: ")

will get you working on the getpoint function.
I've never used timers so I'll need to look into that one Daron

hendie

  • Guest
woohoo, 2nd topic. Speed testing.
« Reply #2 on: October 31, 2003, 06:19:11 AM »
and does this help you with the timer bit
Code: [Select]
Dim StartTime As Long
Dim EndTime As Long
Dim TotalTime As Long
_______________________________________

Private Sub StartTimeR()
StartTime = Timer
End Sub
_______________________________________

Private Sub EndTimeR()
EndTime = Timer
End Sub
_______________________________________

Private Sub CommandButton1_Click()
StartTimeR
'do your stuff in here

EndTimeR
TotalTime = EndTime - StartTime
TextBox1.Text = TotalTime
End Sub

SomeCallMeDave

  • Guest
woohoo, 2nd topic. Speed testing.
« Reply #3 on: October 31, 2003, 08:11:30 AM »
For the insertion test,  you could use

Code: [Select]

Public Function InsertTest()
  Dim i As Integer
  Dim lngStart As Long
  Dim lngEnd As Long
  Dim InsPt(0 To 2) As Double
  Dim mspace As AcadModelSpace
  Set mspace = ThisDrawing.ModelSpace
 
  lngStart = GetTickCount

  For i = 1 To 1000
    mspace.InsertBlock InsPt, "Circ", 1, 1, 1, 0
  Next i
 
  lngEnd = GetTickCount
  MsgBox "Total Time = " & CStr((lngEnd - lngStart) / 1000#)

End Function


InsPt will default to 0,0,0    and you don't really need to set the block reference  (that will just slow you down  :)  )

For timers,  I like to use the API GetTickCount.  It counts by 1000th of a second.  There is a more precise timer,  but it is harder to use.
In a standard module,  insert this timer code.

Code: [Select]

Option Explicit

Declare Function GetTickCount Lib "kernel32" () As Long


SMadsen

  • Guest
woohoo, 2nd topic. Speed testing.
« Reply #4 on: October 31, 2003, 09:24:01 AM »
Just a note: the timer needs to be based on DATE and the formula shown by Daron. Otherwise it won't be comparable to AutoLISP. If VBA is also slower in accessing the sysvars then it's just bad luck :)

daron

  • Guest
woohoo, 2nd topic. Speed testing.
« Reply #5 on: October 31, 2003, 10:25:32 AM »
Okay, here's what I've got so far.
Code: [Select]
Dim StartTime As Long
Dim EndTime As Long
Dim TotalTime As Long

Private Sub starttimer()
StartTime = Timer
'time = ThisDrawing.GetVariable("date")
End Sub

Private Sub endtimer()
'Dim seconds As Long
'time = ThisDrawing.GetVariable("date" - time)
'seconds = (time - time * 86400#)
'output seconds func
EndTime = Timer
End Sub


'Function output()
'MsgBox "Total Time = & CStr((lngEnd - lngStart) / 1000#)"
'End Function

Sub instest()
Dim inspt(0 To 2) As Double
Dim count As Integer
'Dim lngStart As Long
'Dim lngEnd As Long
Dim MSpace As AcadModelSpace
Set MSpace = ThisDrawing.ModelSpace
'lngStart = GetTickCount

'Set blkref = ThisDrawing.ModelSpace.InsertBlock _
'            (inspt, "circ", 1#, 1#, 1#, 0)
starttimer
For count = 1 To 1000
    MSpace.InsertBlock inspt, "Circ", 1, 1, 1, 0
Next count
'lngEnd = GetTickCount
endtimer
End Sub

'Declare Function GetTickCount Lib "kernel32" () As Long

Thanks Dave and Hendie. I took what I could from both of you guys, and it now inserts 1000 "circ" objects at 0,0,0. What I couldn't figure out is Hendie's:
Code: [Select]
Private Sub commandButton1_Click()
StartTime
instest
EndTime
TotalTime = EndTime - StartTime
TextBox1.Text = TotalTime
End Sub

Where do I put it. I tried it in the module, then in a form. I couldn't figure it out in either place.

daron

  • Guest
woohoo, 2nd topic. Speed testing.
« Reply #6 on: October 31, 2003, 10:35:42 AM »
Here is just what Dave put up. I'm not sure what to do with the timer. It's in the module, as is the funciton, but it didn't work.
Code: [Select]
Option Explicit
Declare Function GetTickCount Lib "kernel32" () As Long

Public Function InsTest()
Dim inspt(0 To 2) As Double
Dim i As Integer
Dim lngStart As Long
Dim lngEnd As Long
Dim MSpace As AcadModelSpace
Set MSpace = ThisDrawing.ModelSpace

lngStart = GetTickCount

For i = 1 To 1000
    MSpace.InsertBlock inspt, "Circ", 1, 1, 1, 0
Next i
lngEnd = GetTickCount
End Function


Works super quick, though. Both of them.

SomeCallMeDave

  • Guest
woohoo, 2nd topic. Speed testing.
« Reply #7 on: October 31, 2003, 02:10:02 PM »
Daron,  
The Declare  needs to be in a standard module,  not the ThisDrawing class module.
The rest of the code can go in either place.

Hope this makes sense.

SomeCallMeDave

  • Guest
woohoo, 2nd topic. Speed testing.
« Reply #8 on: October 31, 2003, 02:16:55 PM »
And here is the same function using the sysvar "DATE" for the timer

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


How much faster is LISP than VBA in your tests so far?

daron

  • Guest
woohoo, 2nd topic. Speed testing.
« Reply #9 on: October 31, 2003, 02:45:42 PM »
Even though it felt faster to me the time for the above function was:
Total Time = 0.984987616539001

That is on my machine. Let's see how it goes on the other test machines. I'll post the code in the lisp thread and let others test it. We'll just put it in as SCMDave's version.

daron

  • Guest
woohoo, 2nd topic. Speed testing.
« Reply #10 on: October 31, 2003, 02:58:51 PM »
Quote from: SomeCallMeDave
Daron,  
The Declare  needs to be in a standard module,  not the ThisDrawing class module.
The rest of the code can go in either place.

Hope this makes sense.


They were both in a module and not in thisdrawing. Oh well, the other one works. Here's the link to the race.