Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

connector class

Posted on 1999-07-28
9
Medium Priority
?
286 Views
Last Modified: 2013-11-23
I have created a connector class in vb6 that will return me an reference to an atl object.  The atl object is full of collections.  When I spin through the collections using the connector class the performance seems to be 20 times worse than when connecting to the object directly.  Can I speed up the performance when using the connector class??  The
connector class was modeled after the MSDN "Coffee" example!  Here is how I call the connector and loop.
 
Private oC As scAtlObject
Private oConnector As clsConnector
 
Private Sub cmdConnect_Click()
    Screen.MousePointer = vbHourglass
 
    Set oConnector = New clsConnector
    Set oC = oConnector.clsAtlConnector.oC
 
    Screen.MousePointer = vbDefault
End Sub
 
Private Sub cmdConnectDirect_Click()
 
    Screen.MousePointer = vbHourglass
 
    Set oC = new scAtlObject
    oC.Load
    Screen.MousePointer = vbDefault
 
End Sub
 
Private Sub cmdLoop_Click()
    Dim oTemp as oT
    Dim oTemp2 as oT2
    Dim lStart as Long
    Dim lEnd as Long
 
    lStart = GetTickCount()
    For Each oTemp in oC
        For Each oTemp2 in oTemp
           
        Next
    Next
    lEnd = GetTickCount()
    MsgBox "Time(ms): " & lEnd - lStart
End Sub
0
Comment
Question by:kayee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 2

Expert Comment

by:dhodge
ID: 1527967
Using For Each is perhasps the most obvious time waster here.  It has to establish the item count each time and convert the object into the required type.

Firstly try taking a count before the loop and looping

ncount = oC.Count
for i = 1 to nCount

Do this for both loops.  Then when using the individual object reference it with the item property.

eg.

ncount = oC.Count
for i = 1 to nCount
    nInnerCount = OTemp.Count
    for n = 1 to nInnerCount
        set OTemp2 = oC(i).item(n)
        oTemp2.DoSomething
    next
next
0
 

Author Comment

by:kayee
ID: 1527968
That is a good point, but If I use the existing for each logic the time to loop through my atl object when connected using the connector class is about 5 secs.  I connect directly to my atl object and loop it takes about 20 milliseconds.  Why is this so slow and what can I do to get the same performance as connecting directly?
0
 
LVL 15

Expert Comment

by:ameba
ID: 1527969
Late binding?
Fastest acces is via early binding (vtable)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kayee
ID: 1527970
I use early binding, My atlobject and my activex exe connector are referenced in my vb project.
0
 
LVL 15

Expert Comment

by:ameba
ID: 1527971
I don't see in your code accessing any property.
How are you accesing properties? How you do it when accessing object directly?
0
 

Author Comment

by:kayee
ID: 1527972
When I connect directly, I create a instance of the atlobject by settin oC = new scAtlObject.  Then I can call the method oC.Load which will load all of the collections.  
Then I spin through the collections without accessing any properties to make sure the speed issue isn't in one of the properties.
0
 
LVL 1

Expert Comment

by:bshuler072699
ID: 1527973
Std com objects are slow, ATL is fast. Take any dummy ATL object and any COM object and you will see the same time differences. That is why you took the time to write it in ATL isn't it...
0
 

Author Comment

by:kayee
ID: 1527974
I need some way to have multiple vb clients connect to the existing atl object with good performance.  Is there some other way to do this?
0
 
LVL 1

Accepted Solution

by:
bshuler072699 earned 1000 total points
ID: 1527975
Yes, there is. But your question was "Can I speed up the performance when using the connector class?? " and the answer is, No, not when compared to a ATL object.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question