PDA

Click to See Complete Forum and Search --> : Slow Performance


Dec 8th, 1999, 04:12 AM
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.

Aaron Young
Dec 8th, 1999, 06:03 AM
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

Dec 8th, 1999, 08:27 PM
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.

Inhumanoid
Dec 8th, 1999, 09:31 PM
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...

Dec 9th, 1999, 03:06 AM
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.

Aaron Young
Dec 9th, 1999, 03:35 AM
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.

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

Aaron Young
Dec 9th, 1999, 11:44 AM
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..

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