no, you shouldn't be, but your suggestion started with "If you're running Yosemite, …" and I'm on Mavericks here. So I didn't try anything with your approach.
Thus I couldn't run your script either, I adjusted it for my situation, leaving out ASObjC. For timing I used the OSAX LapTime, I don't know how this compares, but it might intervene somewhat.
The Satimage comes out much slower than when run from AppleScript-Editor, regardless of the warm-up call in the script: it doesn't change significantly when I remove the line
Similarly with Davey's method that uses the Standard Additions OSAX. Is it possible that this is due to the use of the LapTime OSAX?
property Codes : {"9420", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "9470", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "942C", "9470", "94ae", "94d0", "942f", "9471"}
property Mnemonics : {"RCL", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "EDM", "RfW", "ENM", "ReW", "EOC", "RfX"}
set iterationCount to (text returned of (display dialog "Number of iterations:" default answer "1")) as integer
-- time Axel's method
set time1 to start timer
repeat iterationCount times
MnemonicOfAxel("9471") -- Axel's version
end repeat
set a to stop timer time1
-- create tab/return-delimited string for Chris's methods
set theList to {}
repeat with i from 1 to count of Codes
set end of theList to item i of Codes & tab & item i of Mnemonics
end repeat
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {return}
set lookupTable to theList as text
set AppleScript's text item delimiters to saveTID
-- time TIDs method
set time1 to start timer
repeat iterationCount times
lookupMnemonic("9471") -- Chris's TIDs handler
end repeat
set z to stop timer time1
-- call Satimage command to force loading, otherwise time is much longer
try
find text "abc" using
"\\1" in
my lookupTable with regexp
and string result
without case sensitive
end try
-- time Satimage/regex method
set time1 to start timer
repeat iterationCount times
lookupMnemonicSIO("9471") -- Chris's Satimage handler
end repeat
set y to stop timer time1
-- Davey's Method
set AppleScript's text item delimiters to {tab}
set codesList to (Codes as string) & tab
set time1 to start timer
repeat iterationCount times
MnemonicOfDavey("9471") -- Davey's Offset handler
end repeat
set w to stop timer time1
-- build TextEdit doc for Olof's method
set allMnemonics to ""
repeat with n from 1 to count Codes
set allMnemonics to allMnemonics & item n of Codes & ", " & item n of Mnemonics & return
end repeat
tell application "TextEdit"
if not (exists document "Mnemonics") then
make new document with properties {name:"Mnemonics"}
end if
set text of document "Mnemonics" to allMnemonics
end tell
-- time TextEdit doc method
set time1 to start timer
repeat iterationCount times
MnemonicOfTextEdit("9471") -- TextEdit handler
end repeat
set b to stop timer time1
-- show results
display dialog "Results: " & return & ¬
"Satimage/regex: " & setDecimal(y, 2) & return & ¬
"TIDs: " & setDecimal(z, 2) & return & ¬
"Axel's loop: " & setDecimal(a, 2) & return & ¬
"Davey's offset: " & setDecimal(w, 2) & return & ¬
"TextEdit: " & setDecimal(b, 2)
-- Satimage.osax
on lookupMnemonicSIO(_mnemoic)
try
set _mnemoic to "^" &
_mnemoic & "
\\t(.+$)"
find text _mnemoic using
"\\1" in
my lookupTable with regexp
and string result
without case sensitive
on error
return false
end try
end lookupMnemonicSIO
-- use TIDs
on lookupMnemonic(_mnemoic)
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {_mnemoic & tab}}
set _output to paragraph 1 of text item 2 of my lookupTable
set AppleScript's text item delimiters to oldTIDS
return _output
end lookupMnemonic
on MnemonicOfAxel(aCode)
local k
repeat with k from 1 to length of my Codes
if item k of my Codes is aCode then return item k of my Mnemonics
end repeat
return missing value
end MnemonicOfAxel
on MnemonicOfTextEdit(aCode)
tell application "TextEdit"
set theParagraphs to every paragraph of document "Mnemonics" where it begins with aCode
end tell
return ((characters 7 thru -2 of item 1 of theParagraphs) as text)
end MnemonicOfTextEdit
on MnemonicOfDavey(aCode)
set k to offset of aCode & tab in my codesList
if k = 0 then return missing value
return item (1 + k div 5) of Mnemonics
end MnemonicOfDavey
on setDecimal(theNumber, theDigits)
set myInteger to round (theNumber * (10 ^ theDigits))
return myInteger / (10 ^ theDigits)
end setDecimal