Original post -->
bb/viewtopic.php?p=12136#p12136
(Photoshop 12.0.3 x64, Windows)
Test 0: times 8778,8702,8643, min. duration: 8643 (sTID w/o caching) =>
Test 1: times 3365,3379,3392, min. duration: 3365 (sTID w/ caching)
Test 2: times 5493,5496,5500, min. duration: 5493 (direct app.stringIDToTypeID call)
Test 3: times 7264,7285,7261, min. duration: 7261 (cTID w/o caching)
Test 4: times 3197,3194,3201, min. duration: 3194 (cTID w/ caching)
Test 5: times 4455,4447,4451, min. duration: 4447 (direct app.charIDToTypeID call)
Code: Select all#target photoshop
var iter = 1000000;
var testCase0 = function() {
sTID = function(s) { return app.stringIDToTypeID(s); };
for ( var i=0; i<iter; ++i ) {
sTID('vectorMask');
sTID('pathContents');
sTID('subpathListKey');
sTID('anchor');
}
}
var testCase1 = function() {
sTID = function(s) { return sTID[s] || sTID[s] = app.stringIDToTypeID(s); };
for ( var i=0; i<iter; ++i ) {
sTID('vectorMask');
sTID('pathContents');
sTID('subpathListKey');
sTID('anchor');
}
}
var testCase2 = function() {
for ( var i=0; i<iter; ++i ) {
app.stringIDToTypeID('vectorMask');
app.stringIDToTypeID('pathContents');
app.stringIDToTypeID('subpathListKey');
app.stringIDToTypeID('anchor');
}
}
var testCase3 = function() {
cTID = function(s) { return app.charIDToTypeID(s); };
for ( var i=0; i<iter; ++i ) {
cTID('setd');
cTID('null');
cTID('Prpr');
cTID('Lefx');
}
}
var testCase4 = function() {
cTID = function(s) { return cTID[s] || cTID[s] = app.charIDToTypeID(s); };
for ( var i=0; i<iter; ++i ) {
cTID('setd');
cTID('null');
cTID('Prpr');
cTID('Lefx');
}
}
var testCase5 = function() {
for ( var i=0; i<iter; ++i ) {
app.charIDToTypeID('setd');
app.charIDToTypeID('null');
app.charIDToTypeID('Prpr');
app.charIDToTypeID('Lefx');
}
}
var test = [testCase0, testCase1, testCase2, testCase3, testCase4, testCase5]
var repeatCount = 3;
for (var t in test) {
var shortestTime = +Infinity, timings = [];
for (var i=0; i<repeatCount; ++i) {
var start = Date.now();
test[t]();
var duration = Date.now()-start;
timings.push(duration);
if (duration < shortestTime) shortestTime = duration;
}
$.writeln("Test " + t + ": times " + timings + ", min. duration: " + shortestTime);
}