Copy link to clipboard
Copied
Copy link to clipboard
Copied
(function() {Result: Just over seven seconds -- consistently for a number of runs.
if (app.documents.length > 0 &&
app.selection.length > 0) {
var aDoc = app.documents[0];
var myStartTime = new Date();
for (var j = 100; j >= 1; j--) {
//save users measurement preferences
var userHoriz = aDoc.viewPreferences.horizontalMeasurementUnits;
var userVert = aDoc.viewPreferences.verticalMeasurementUnits;
aDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
aDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
//restore users measurement preferences
aDoc.viewPreferences.horizontalMeasurementUnits = userHoriz;
aDoc.viewPreferences.verticalMeasurementUnits = userVert;
}
var myEndTime = new Date();
var myDuration = (myEndTime - myStartTime)/1000; // Times are in milliseconds
alert(myDuration);
}
}())
(function() {Just over seven seconds consistently across a number of runs. So that's wiped that smug smile off my face!
if (app.documents.length > 0 &&
app.selection.length > 0) {
var aDoc = app.documents[0];
var myStartTime = new Date();
for (var j = 100; j >= 1; j--) {
//save users measurement preferences
with (aDoc.viewPreferences) {
var userHoriz = horizontalMeasurementUnits;
var userVert = verticalMeasurementUnits;
horizontalMeasurementUnits = MeasurementUnits.points;
verticalMeasurementUnits = MeasurementUnits.points;
}
with (aDoc.viewPreferences) {
//restore users measurement preferences
horizontalMeasurementUnits = userHoriz;
verticalMeasurementUnits = userVert;
}
}
var myEndTime = new Date();
var myDuration = (myEndTime - myStartTime)/1000; // Times are in milliseconds
alert(myDuration);
}
}())
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
with (myTF.textFramePreferences) {But here this issue is not so much with the with construct as with the fact that doing this leads to two (in this case) interactions with the object model, while this:
textColumnCount = 2;
textColumnGutter = 12;
}
myTF.textFramePreferences.properties = {requires only one.
textColumnCount: 2,
textColumnGutter: 12
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
myTF= app.selection[0];First alert: 0.5 seconds, second: 2.9 seconds, third: 2.5 seconds.
var myStartTime = new Date();
for (var j = 0; 100 > j; j++) {
myPrefs = myTF.textFramePreferences;
myPrefs = textColumnCount = 2;
myPrefs = textColumnGutter = 12;
}
var myEndTime = new Date();
var myDuration = (myEndTime - myStartTime)/1000; // Times are in milliseconds
alert(myDuration)
var myStartTime = new Date();
for (var j = 0; 100 > j; j++) {
with (myTF.textFramePreferences) {
textColumnCount = 2;
textColumnGutter = 12;
}
}
var myEndTime = new Date();
var myDuration = (myEndTime - myStartTime)/1000; // Times are in milliseconds
alert(myDuration)
var myStartTime = new Date();
for (var j = 0; 100 > j; j++) {
myTF.textFramePreferences.properties = {
textColumnCount: 2,
textColumnGutter: 12
}
}
var myEndTime = new Date();
var myDuration = (myEndTime - myStartTime)/1000; // Times are in milliseconds
alert(myDuration)
Copy link to clipboard
Copied
myTF= app.selection[0];First loop: 3.0 seconds; Second loop: 2.8 seconds; Third loop: 2.2 seconds (all this on a G4/800MHz).
var myStartTime = new Date();
for (var j = 0; 100 > j; j++) {
myPrefs = myTF.textFramePreferences;
myPrefs.textColumnCount = 2;
myPrefs.textColumnGutter = 12;
}
var myEndTime = new Date();
var myDuration = (myEndTime - myStartTime)/1000; // Times are in milliseconds
alert(myDuration)
var myStartTime = new Date();
for (var j = 0; 100 > j; j++) {
with (myTF.textFramePreferences) {
textColumnCount = 2;
textColumnGutter = 12;
}
}
var myEndTime = new Date();
var myDuration = (myEndTime - myStartTime)/1000; // Times are in milliseconds
alert(myDuration)
var myStartTime = new Date();
for (var j = 0; 100 > j; j++) {
myTF.textFramePreferences.properties = {
textColumnCount: 2,
textColumnGutter: 12
}
}
var myEndTime = new Date();
var myDuration = (myEndTime - myStartTime)/1000; // Times are in milliseconds
alert(myDuration)
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied