Code Red > VB(A)

woohoo, 2nd topic. Speed testing.

(1/3) > >>

daron:
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: ---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
--- End code ---

hendie:
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: ---
Dim inspnt As Variant
Me.Hide
inspnt = ThisDrawing.Utility.GetPoint(, "Enter a point: ")
--- End code ---

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

hendie:
and does this help you with the timer bit

--- Code: ---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

--- End code ---

SomeCallMeDave:
For the insertion test,  you could use


--- Code: ---
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

--- End code ---


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: ---
Option Explicit

Declare Function GetTickCount Lib "kernel32" () As Long


--- End code ---

SMadsen:
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 :)

Navigation

[0] Message Index

[#] Next page

Go to full version