Results 1 to 7 of 7

Thread: Slow Performance

  1. #1
    Guest

    Post

    Hi,

    I'm working with an application that extracts information from MS Project. It's dog slow. The code in this VB exe will run 10X faster in a Macro within Project itself.

    Any tips for improving the exe speed (aside from processor/ram).

    Thanks.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Without seeing the Specific Part(s) of the Code it's difficult to say, other than Recommending you look at General Performance Tuning Tips.

    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

  3. #3
    Guest

    Post

    I've tried all the MS "Optimizing Code" and "Speeding Object References" tips. No real gains.

    Pseudo code looks like -

    Dim T As Task
    Dim objMSProject As MSProject.Application

    Set objMSProject = New MSProject.Application

    'Open predetermined mpp file
    objMSProject.Application.FileOpen Name:=SDIR & myfile, ReadOnly:=True

    ' Loop thru all tasks
    For i = 1 To objMSProject.ActiveProject.Tasks.Count

    Set T = objMSProject.ActiveProject.Tasks(i)

    ...some code pulling data from the Task properties

    Next

    - that's about it. Any advise would be greatly appreciated.

  4. #4
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    I don't know anything about Project but if a macro can do what your exe does, maybe you should create a VB exe that generates a Macro wich could be automaticly imported by Project and then executed...

    But then maybe all this stuff is not possible...

  5. #5
    Guest

    Post

    Aaron,

    Thanks for the suggestions.

    Considering this routine is only executed once - I left the declares.

    To get some estimates I ran the following sets of code against a Project Plan with around 500 tasks (i.e. the For-Loop will execute 500 time)

    1. Elapsed time - 8 seconds
    ============================================
    Dim T As Object
    Dim objMSProject As New MSProject.Application

    Open "C:\active\test2.txt" For Output As #1

    objMSProject.FileOpen ("c:\active\CNV_MIG.mpp")

    Set T = objMSProject.ActiveProject.Tasks
    For i = 1 To T.Count
    Print #1, T(i).Name
    Next


    2. Elapsed time - 9 seconds
    ============================================
    Dim Z As Object
    Dim T As Task
    Dim objMSProject As New MSProject.Application

    Open "C:\active\test2.txt" For Output As #1

    objMSProject.FileOpen ("c:\active\CNV_MIG.mpp")

    Set Z = objMSProject.ActiveProject.Tasks
    For Each T In Z
    Print #1, T.Name
    Next


    3. 1st set of code within a MSProject 98 macro - elapsed time 1 second
    ==========================================

    Open "C:\active\test3.txt" For Output As #1

    FileOpen ("c:\active\CNV_MIG.mpp")

    Set t = ActiveProject.Tasks
    For i = 1 To t.Count
    Print #1, t(i).Name
    Next


    You can see the potential for huge time differences. This example works with ONE of the hundreds of potential properties within Project 98...

    Thinking this may touch on "In-Process vs. Out-Of-Process". Just not sure at this time.

    Thanks Again. Rick.

  6. #6
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    Another thing you may want to consider looking at your new examples, is building the results of the Loop into a String, then write it to the File in one Go, instead of making Multiple File Accesses in the Loop Making it much, much slower, eg.
    Code:
    Dim T As Object
    Dim objMSProject As New MSProject.Application
    Dim sOuput As String
    
    objMSProject.FileOpen ("c:\active\CNV_MIG.mpp")
    
    Set T = objMSProject.ActiveProject.Tasks
    sOutput = ""
    For i = 1 To T.Count
        sOutput = sOutput & T(i).Name & vbCrLf
    Next
    Open "C:\active\test2.txt" For Output As #1
        Print #1, sOutput
    Close 1
    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

  7. #7
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    From what you've posted..

    If that whole chunk of code is repeated several times in the Program, you could try declaring the ObjMSProject Object Globally, that way you won't need to recreate it everytime.

    Also, you shouldn't need to Dim the Object then Set it to New, you should be able to do Dim objMSProject As New MSProject.Application instead.

    In the For..Next Loop it would probably be more efficient to set T to the objMSProject.ActiveProject Before the Loop, instead of Resetting it to each Object in Tasks, eg.

    Psuedo..
    Code:
    Private T As Object
    Private objMSProject As New MSProject.Application
    
    Private Sub SomeSubRoutine()
        'Open predetermined mpp file 
        objMSProject.FileOpen Name:=SDIR & myfile, ReadOnly:=True
    
        ' Loop thru all tasks
        Set T = objMSProject.ActiveProject
        For i = 1 To T.Tasks.Count
            ...some code pulling data from the T.Task(i) properties
        Next
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width