I have discovered painfully that references to task properties in the form of
Activeproject.tasks(ID).name
and even
TS(ID).name
after the required
'Dim TS as tasks
Set TS = ActiveProject.tasks'
are hugely expensive statements to use.
I have also learnt (see previous post) that the execution time for traversing a list of N tasks is proportional to N*N rather than the expected N. That is, if you double the number of tasks, you quadruple the execution time.
Put these two effects together, that is, use code that traverses a big task list AND uses these property references for each task and you get a blowout in time.
The two effects are summarised in the table below. The column for 'Ref' contains execution time (in seconds) for some menial code that traverses the entire list of tasks (25 and then 50 in number) and involves three lines containing a reference 'ActiveProject.Tasks(ID).name' for each row while the one in 'No Ref' relates to the identical code except that the reference statements are replaced by three ordinary assignment statements such as 'z = 1'.
N Ref Non Ref
25 5.95 0.19
50 23.03 0.74
Compare the two columns to see how expensive reference statements are. Compare the two rows to see how the execution time behaves on doubling the number of tasks.
My question to anyone is: Is there a more efficient way of referencing task (and resource assignment) properties than the method shown above, so that I can dramatically reduce the time taken to run my application.
Help would be greatly appreciated.
Thank you.
Activeproject.tasks(ID).name
and even
TS(ID).name
after the required
'Dim TS as tasks
Set TS = ActiveProject.tasks'
are hugely expensive statements to use.
I have also learnt (see previous post) that the execution time for traversing a list of N tasks is proportional to N*N rather than the expected N. That is, if you double the number of tasks, you quadruple the execution time.
Put these two effects together, that is, use code that traverses a big task list AND uses these property references for each task and you get a blowout in time.
The two effects are summarised in the table below. The column for 'Ref' contains execution time (in seconds) for some menial code that traverses the entire list of tasks (25 and then 50 in number) and involves three lines containing a reference 'ActiveProject.Tasks(ID).name' for each row while the one in 'No Ref' relates to the identical code except that the reference statements are replaced by three ordinary assignment statements such as 'z = 1'.
N Ref Non Ref
25 5.95 0.19
50 23.03 0.74
Compare the two columns to see how expensive reference statements are. Compare the two rows to see how the execution time behaves on doubling the number of tasks.
My question to anyone is: Is there a more efficient way of referencing task (and resource assignment) properties than the method shown above, so that I can dramatically reduce the time taken to run my application.
Help would be greatly appreciated.
Thank you.