-
-
2. Re: Execution time
sanjascreenname Sep 30, 2013 2:12 AM (in response to Andreas Jansson)The difference in the code is only 1 extra for loop. Nothing else.
All the code is running same amount of times in examples, I mean it gets executed the same amount of times.
I think that ExtendScript engine has some optimization for this (memory management?!), but i don’t know which optimization because I can’t find any documentation on the engine and the way it works.
-
3. Re: Execution time
Andreas Jansson Sep 30, 2013 3:00 AM (in response to sanjascreenname)You have 1 extra loop in example number 2 (looping 50 times). But inside that loop you still do the same loop that you have got in example number 1.
Where is framesTotal set? And what is the value of it?
-
4. Re: Execution time
sanjascreenname Sep 30, 2013 3:25 AM (in response to Andreas Jansson)framesTotal is 100 frames, and I have them on a master page.
The extra for loop in the second example is a loop that I use to override all master text frames on every page.
In first example I deleted that loop, and pages get overriden in the second loop.
I do overriding of frames the same amount of times in both examples. 5000 frames total get overridden.
-
5. Re: Execution time
Andreas Jansson Oct 1, 2013 6:11 AM (in response to sanjascreenname)Yes, sorry, you are right, my mistake.
Could you check whether the time for linking is low at first, and then increasing in sample 1, and if the time to relink is long, from the beginning, in sample 2?
And / or time the override calls, to get to know what part of the code that is the problem.
-
6. Re: Execution time
sanjascreenname Oct 1, 2013 6:18 AM (in response to Andreas Jansson)I have already measured the times
First example;
Override 89 sec
Linking 41 sec
Second example;
Override 96 sec
Linking 137 sec
-
7. Re: Execution time
Vamitul Oct 1, 2013 11:55 PM (in response to sanjascreenname)The difference is caused by the extra for. More exactly it is caused by the extra DOM acess. Your first script goes over 50 pages, and for each it does it stuff. The second one, goes over 50 pages, overrides everything, then again goes over 50 pages and links stuff. Quite a lot more overhead.
Now, there are quite a lot of ways you can optimize even the first one (i am assuming all your variables are predeclared somwhere, not globals).
For examle, just replacing the txt2 line to something like this:
txt2=page.textFrames.item(frameNumb);
will give you a nice speed boost (general javascript object caching).
Add just before closing the outer loop a line like:
prevPage=page;
and change the txt1 line to
txt1=prevPage.textFrames.item(frameNumb);
and the execution time will be.. i don't know, but i'm guessing about half..
also, make sure you have scriptRedraw set to false.
Good luck
-
8. Re: Execution time
sanjascreenname Oct 2, 2013 12:15 AM (in response to Vamitul)Actually, at the end I did this and got the best times….
for (pg=1; str<50; pg++) {
framesMaster.override(pgDoc.item(pg));
page1=pgDoc.item(pg).textFrames.everyItem().getElements();
page=pgDoc.item(pg-1).textFrames.everyItem().getElements();
for (frameNumb=0; frameNumb<framesTotal; frameNumb++) {
page[frameNumb].nextTextFrame=page1[frameNumb];
}
}


