AppleScript speed difference between 10.4 & 10.5

This post is related to a question I posed in March 2009 (https://discussions.apple.com/message/9226100) regarding the speed difference between AppleScript text handling in OS X 10.5 compared with 10.4.11.
I have recently written a script to search through a text file which is an xml file exported from WorkGroup Manager. The file, which is approximately 1.8 MB, contains all the user names on the school server (just over 1720 of them), their settings and any other information we have added. After adapting some script ideas (using text delimiters and offsets) which I found on the internet to assist with counting the number of users and searching through the information of each one, one at a time, I have a script which works far in excess of my expectations in terms of speed when run under OS X 10.4, but runs slower than molasses in winter under 10.5.
The script counts the number of accounts, extracts each user's log-in name and also their actual name (which we have entered under a 'general info' or 'comments' field - I can't remember exactly where, but it is stored in the file), makes up a complete list of all account names (with the actual name, if present) and also makes up a subset of this information into a separate list which contains only the log-in names of those whose actual name has not yet been recorded on the server, then saves both lists to separate text files.
My original attempts, using some rather clumsy text searching and comparison techniques, took about 1-2 minutes to go through the whole procedure. After some internet searching, head-scratching and a bit more more work, the finished script, when run on my G5 under OS X 10.4.11, takes less than 3 seconds to do all I have described above, including the writing to text files. To say I was pleased would be an understatement!
Because the school/work environment, where the script would be run, is all OS X 10.5 or higher, I thought I should test it out under at least OS X 10.5. The script was developed on my DP 2.5GHz G5 with 8GB RAM running OS X 10.4.11. Using a fresh, clean installation of 10.5 I ran the script and was extremely disappointed. After letting it run for more than 20 minutes and still not finishing, I force quit AppleScript and reduced the number of accounts in the file. 40 accounts took 3 seconds, 60 accounts took 6 seconds, 80 took 11 seconds, 100 took 19 seconds and 120 took 27 seconds. I eventually let the script run right through - total time taken to process 1720 users was 65 minutes, compared to 3 seconds under 10.4.11!
Given that it was tested on the same Mac, with the same amount of RAM, using the same script and the same original text file, the only variable left (that I can think of) is the change of OS version - 10.4.11 vs 10.5.
As was pointed out to me in my previous post, AppleScript in OS X 10.5 handles all text as Unicode and has a greater overhead in processing time as a result. I have implemented the various bits of advice offered by respondents to my original post and changed the way I handled lists, etc. Obviously, if the script works so speedily under 10.4.11, I must have done something right in terms of code optimization/efficiency. It's when that exact same script is run under OS X 10.5 that it slows down incredibly. I even tried it on a 2.66GHz Intel Core 2 Duo iMac running 10.5.8 - it still took 40 minutes and Activity Monitor showed CPU usage by Script Editor constantly above 80% (often well above 90%). Saving the script as an application made no difference in the time taken.
Does anybody have any knowledge about what makes AppleScript Unicode-only text handling so slow? In this case, it is 1300 times slower! Is there any way of coercing/restricting the text handling/parsing to ASCII? If I really have to, I will set up a humble eMac at school with 10.4 on it just to handle large text files quickly with AppleScript, but I would prefer to be able to do it on the normal work Macs which have 10.5 or later on them. As mentioned, under 10.4.11 the script processes the 1.8MB text file with 1720 users and writes results to two files - all within 3 seconds, so I'm not really looking for coding suggestions unless they are directly related to what has changed in AppleScript under OS X 10.5. Without sounding too smug, the script works properly and speedily (at least in 10.4). I really would like to learn about the changes in AppleScript in OS X 10.5 and how to cope with or work around those changes.

Hi,
text 3 thru 14 in largeText
character 3 thru 14 in largeText
text 3  in largeText
character 3  in largeText
These lines will be slow on Leopard
Getting some text in a variable that contains more than 60000 characters will be slower on Leopard,
but I don't know why it's slower
Here a test script.
script o
    property t_text : ""
end script
set a to "abcdefghij"
set tResult to ""
repeat with i from 1 to 3
    set o's t_text to a
    repeat (item i of {17, 15, 14}) times
        set o's t_text to o's t_text & o's t_text -- add  characters in the variable
    end repeat
    set StartTime to current date
    -- test
    repeat 20 times
        set b to text 3 thru 14 in o's t_text -- get a text in the variable
    end repeat
    -- end test
    set EndTime to current date
    set TimeTaken to EndTime - StartTime
    set tResult to tResult & " Getting text in the variable which contains " & length of o's t_text & ", (20 times) = " & TimeTaken & " seconds." & return
end repeat
tResult
Here the result on my old G5, 2 x 1.8 GHZ
Getting text in the variable which contains 1310720 characters, (20 times)  = 50 seconds.
Getting text in the variable which contains   327680 characters, (20 times)  = 12 seconds.
Getting text in the variable which contains   163840 characters, (20 times)  =   6 seconds.
The result on the same machine on Tiger is always less of one second.
Also, I try with 20 millions characters on Tiger, the result : getting text in the variable which contains 20971520 characters, (20 times)  = 0 seconds.
The solution ( text item in a list)
Here the script
script o
    property my_List : {}
end script
set OldDelims to text item delimiters
set RecordDelimiter to "::::::::::::::"
set LengthOfRecordDelimiter to length of RecordDelimiter
set o's my_List to findAll(read (choose file), RecordDelimiter)
on findAll(str, findString)
    set Oldtid to text item delimiters
    try
        set text item delimiters to findString
        if str does not contain findString then return {"Nothing found"}
        set t to str's text items
        set text item delimiters to Oldtid
        return t
    on error eMsg number eNum
        set text item delimiters to Oldtid
        error "Can't findAll: " & eMsg number eNum
    end try
end findAll
set NumberOfrecords to (count o's my_List)
display dialog "There are " & NumberOfrecords & " accounts."
set StartTime to current date
set text item delimiters to ":"
set FullUserList to {}
set ListOfUnnamedUsers to {}
-- first user needs to be done separately as it is not preceded by RecordDelimiter
set EndOfHeader to "Standard:URL"
set LengthOfEndOfHeader to length of EndOfHeader
set EndOfHeaderOffset to the offset of EndOfHeader in (item 1 of o's my_List)
set OffsetToApply to EndOfHeaderOffset
set TextBeingChecked to text (OffsetToApply + LengthOfEndOfHeader + 1) thru -1 of (item 1 of o's my_List)
tell TextBeingChecked to set {UserName, NameForInfo} to {text item 1, text item 7}
if NameForInfo = "" then set end of ListOfUnnamedUsers to UserName & return
set end of FullUserList to (UserName & tab & NameForInfo & return)
-- now do all the others
repeat with CounterG from 2 to (NumberOfrecords - 1)
    set TextBeingChecked to item CounterG of o's my_List
    tell TextBeingChecked to set {UserName, NameForInfo} to {text item 1, text item 7}
    if NameForInfo = "" then set end of ListOfUnnamedUsers to UserName & return
    set end of FullUserList to (UserName & tab & NameForInfo & return)
end repeat
set o's my_List to {}
set text item delimiters to OldDelims
-- write results to file
-- 1). full user list
set TargetFile1 to (path to desktop folder as string) & "FullUserList1.txt"
try
    open for access file TargetFile1 with write permission
on error
    close access file TargetFile1
    open for access file TargetFile1 with write permission
end try
set EndTime to current date
beep
set InfoToBeWrittenToFile to FullUserList as text
write InfoToBeWrittenToFile to file TargetFile1
close access file TargetFile1
-- 2). list of users without NameForInfo
set TargetFile2 to (path to desktop folder as string) & "UnnamedUsersList1.txt"
try
    open for access file TargetFile2 with write permission
on error
    close access file TargetFile2
    open for access file TargetFile2 with write permission
end try
set InfoToBeWrittenToFile to ListOfUnnamedUsers as text
write InfoToBeWrittenToFile to file TargetFile2
close access file TargetFile2
beep 3
set TimeTaken to EndTime - StartTime
set TimePerAccount to TimeTaken / NumberOfrecords
display dialog (NumberOfrecords & " accounts took " & TimeTaken & " seconds." & return & return & "That equals " & TimePerAccount & " seconds per account.") as string

Similar Messages

  • Any speed difference between Apple Wifi Router(air express) and Tp link(or others) wifi router)

    Any speed difference between Apple Wifi Router(air express) and Tp link(or others) wifi router?
    I'm using a tp link router and sometimes it takes a long time delay for my 2 mac computers to connect each other. I don't know this is because of the router compability or the computers.

    Anyone knows?

  • Speed difference between comressor 1 & 2

    I've ben working on a contract that requires me to use Compressor (2). I usally set up a batch of 3 timelines (with DVD SP markers) to for a total of 1 hour of content. Using Compressor's setting for 90 min. fast encode on my DP 1 GIG desktop this takes approx 7 hours and on my G4 1.25 laptop it takes 10 hours. A friend did a simillar compression on a single QS 867 mhz with 1.5 GIG of ram and this took 5 hours. Is it possible there is so much difference between Compressor 1 vs. 2?
    Jeff
    G4 DP 1 GIG G4 laptop 1.25   Mac OS X (10.4.6)  

    Hi Hanumang/ John
    I'm haveing a hard time understanding this myself. The settting I used in Compressor 2 was the fast encode 90 min which is 6.2mbps 1 pass & Dolby 2.0. The compreson I told my friend to use (using Compressor 1) was also a preset This was the 60 min. fast encode @ 6.0mbps. Although his was doing video only, then running the audio through Apack which would only take 20 mins. at most. These are very simple timelines with no effects and jus a few DVD SP markers. If it is a speeed difference of at least 30% my purchase of a MBP 1.83 (for added speed, may not be fully realized when using Compresor.
    Jeff
    G4 DP 1 GIG G4 laptop 1.25, MBP 18   Mac OS X (10.4.6)  

  • Speed difference between i7 quad 3rd gen 2.6ghz and i7 quad 4th gen 3.1ghz?

    How much speed difference in Logic X will I notice between an i7 quad 3rd gen 2.6ghz and i7 quad 4th gen 3.1ghz?
    both loaded with 16gb 1600 ram... 256gb ssd

    Kappy wrote:
    All other things being equal 4-cores are twice as fast as 2-cores. This is regardless of what you are doing. The only way a 2-core processor would be as fast is if it were run at twice the clock speed. But the 2-core CPU is only clocked around 10% or so faster. Now, for all that you claim you will be doing the relevant question is do you need 4-cores. My answer is that you don't. But the 2-core machine will be slower - all things being equal.
    Iris is a far better GPU than HD4 or 5000. But not as fast as a discreet GPU with better performance measures. Again, you don't really need high-power GPU. Iris should meet your needs adequately for now.
    But remember you want to keep the computer for 6 or 7 years. No one knows what your needs will be then. You may find whatever you buy today that meets today's needs will be inadequate for tomorrow's.
    Your comments on graphics pretty much confirm the majority of what I've been reading on other sites.
    The conflict is with cores. About half the people are saying for low CPU intensive tasks 4 cores are totally unnecessary, while the other half says they'll make things faster no what the task (one thing all seem to have in common is they're totally against the 2014s).
    So it seems I'm left with the decision between faster performance vs better graphics.
    I appreciate your input.

  • Real world performance/speed difference between 3ghz and 3.2

    Hello,
    I have a 2008, (not clovertown) Harpertown 3.0ghz Mac Pro. I wanted to know if its feasible to upgrade the cpus to the 3.2 ones? Also, what is the REAL WORLD speed/performance difference between the 3.0 and 3.2? I am so stressed out over this that I really need to have an answer to this.
    Not that I am going to buy the 3.2 processors, just wanting to see what I am missing here in terms of percentage overall between my mac pro and a 3.2ghz mac pro from 2008.
    Thank you,

    You realize that by now you can probably guess what some of our answers might be?
    Real world... well, in the real world you drive to work stuck in traffic most of the time, too.
    Spend your money on a couple new solid state drives.
    You want this for intellectual curiosity, so look at your Geekbench versus others.

  • Is there much speed difference between the iMacs?

    Just wondering, if there is any noticeable performance difference between the 1.83 - the 2.0 and the 2.16?
    I'd be surprised to learn that there was (and also, keenly interested to learn).
    My experience is that a dual processor is noticeably more capable than a single processor (regardless of minor increments at the end of the processor number).
    Anyone?

    You are right that it is more about futher differentiating the models than anything else. The speed difference is negligible, but a nice plus is you choose a larger display. Typically you also get a larger standard HD and maybe a better video card and if you add all those things up, the price difference is worth it.

  • Any data on speed differences between 2.4 and 2.93 ghz MBP?

    Has anyone seen any performance tests showing the difference between 2.4 and 2.93 ghz MBP? I've googled around and haven't found anything.

    Check Bare Feats for benchmarks and do some Google searching. Logically, the difference is not likely more than the difference in processor speed, plus or minus.

  • Speed difference between hotspot and cellular

    Looking at an iPad mini, I have a hot spot on my phone, so I'm wondering how much of a speed difference there might be using a Mini with an iPhone 5 hotspot with AT&T and AT&T cellular on the Mini.

    Download an app such as Speedtest to your iPad.  Test both ways and see the results for yourself.

  • Speed Differences Between 2.66ghz i7 15" and 17" models

    The specs on the top of the line 15&17" 2.66ghz i7 Macbook Pros appear to be identical.
    Aside from cosmetic differences, (like express card vs SD, or the presence of extra ports), can someone please tell me if there are performance differences between these two models?
    Would the 15" be as fast as the 17", for instance, in rendering a quicktime movie to h.264 mpeg-4?
    On a second not, I know they are also apples and oranges, but how fast would these new laptops be compared to my 2008 2.8 ghz dual quad core Mac Pro? Is my Mac Pro still faster than these laptops? I know I would get blazed by the new i7 iMac.

    The specs are identical, unless you consider it useful to have an ExpressCard slot to connect eSATA drives and various other devices, or to have 30% more screen real estate than the hi-res 15" model (or 78% more than the lo-res version). Performance-wise, the machines should be almost exactly alike.
    Your Mac Pro will still outperform either.
    Message was edited by: eww

  • Combined PDF page display speed difference between Acrobat 8 Pro and Acrobat X Pro

    I have encountered a display speed issue with regards to combining Tiffs with Acrobat X Pro.  The Tiffs are between 200 KB and 600 KB.  Tested the issue by using a series of Tiffs originally combined using Acrobat 8 Pro but used Acrobat X Pro to combine them.  When I open the combined PDF files using X, I can cycle through the pages of the one created using 8 significatinly faster (i.e. about as fast as I can click) but the file created using X is significately slower.  Note: PDF file size is smaller using X (30.9 MB) than same combined files using 8 (46.1 MB).  Any ideas on what might be causing this issue?

    Found a Tips & Tricks document for Acrobat 8 which indicated the default Monochrome Compression setting for Acrobat 8 is CCITT G4.  Recreated the combined PDF file from the original Tiffs using X Pro with the modified setting and works like a charm.  Thanks for the point in the right direction.

  • Speed Difference between IPSEC VPN vs Client VPN?

    I'm trying to find out why one connection type is faster than the other for a network links between China and the US.  I'm running iPerf on clients at two diffent sites and was tasked to find out the connection speeds between the two sites.  The results are odd because connecting through our IPSEC VPN we acheive speeds of .83Mbps and going through a Cisco VPN client speeds increase to 1.35Mpbs.  The odd this is that all the hardware is the same between the two.  Both VPN types connect through the same modems and ASA and they are connecting the same two workstations.
    Can anyone here help explain what the cause for the speed discrepancy is?  I don't know enough about VPN to begin to explain why.  I've included some information here, but since I don't know much about this in the first place, if more is needed I'll include it as people ask.  Any help will be appreciated.  Diagram below.
    _Mark

    Hi
    We are having issues with our users from Shanghai office using cisco vpn client, the connection drops very frequently, our IPsec tunnel from Shanghai to the US is more stable. Is your vpn connection stable or your just having speed issues ?

  • Is the speed difference between an i386-optimized distro...

    ...and an i686-optimized distro noticeable on a really high-end computer (Pentium 3.2 GHz)?

    Yes there are.
    This is a very simplistic explanation so also very newbe can understand, there forgive me for the naive language.
    Basically i386 processor compared to an i686 has a very limited set of instruction, so that mean for particular i686 instruction an i386 has to execute more instructions to obtain the same result of 1 instruction on i686.
    If you compile for i386 even if the program run on i686 processor it will execute more instruction (because it contain them) than an optimized executable for i686.
    Having an executable for i386 means also that it "contains more instruction" so it will use more ram to execute.
    At speed execution level there are very discordant opinion.
    There are people that say there are no difference, other says that there is a gain of 5-10%, few say that the performace are worst. Personally I think depends on the kind of use.
    The problem is that is very difficoult to make a precise comparison.
    To be sure you need 2 twins machine and use exaclty the same distribution, one compiled for i386 and the other compiled for i686 with exacly the same installation and configuration.
    Also in this case depens on the kind of application you use.
    For instance i686 has a subset of instruction for "multimedia" so probably if you use application that do a large use of these instruction the speed gain is more evident than if you compare vim use. 
    On very hig end machine this difference should become less relevant since the execution time  became more little.
    Example: on my 500MHZ processor an i386 program take  10 minutes to perform an operation so the equivalent i686 should take 1 minute less so 9 minute.
    other machine, 10000MHz processor the same i386 program take 10 second to perform the same operation, so the i686 versione should take 1 second less that mean 9 second.
    In both cases the gain is 10% but of course on shorter execution time the gain is less evident.
    But thinkg to a lot of application running all togheter on the long time the sum of all the time gain make a difference.
    So mostly depens on the use.
    Anyway using i686 optimized code does not make think worse......

  • Noticeable speed difference between 5400 and 7200?

    My Mac dealer suggests two HD upgrades for the new Mini:
    Either the 5400 rpm WD5000BEVT
    or
    HD intern Momentus 320 GB Sata 2.5" 7200 RPM 16MB
    Anybody knows if the WD5000BEVT offers any speed speed advantages worth mentioning over the standard Mini disks?
    With the HD intern Momentus 320 GB Sata 2.5" 7200 RPM 16MB, I'm not sure about the extra heat and consequent fan noise.
    I do use FCP 6, but no other Studio applications.
    Thanks,

    The greater density of the platters on the 500GB drive will make it faster than a 320GB 5400rpm drive compared to a 320GB 7200rpm drive, though the latter will still be faster. I'd go with the 500GB drive (which I did end up doing with my MBP) due to greater capacity, lower noise, and it's still fast.

  • INternet speed difference between iMac and MBP

    I have an imac 27" that is barely one year old and a three year old MBP. Today, I signed up for faster Fios internet service which is supposed to be a maximum of 25 Mbs both up and down. I then checked the speed on my iMac and see I am averaging about 10 Mbs down and about 8 Mbs up. I am not that concerned that I am not getting the theoretical maximum performance. For one thing I am not hardwired to my router but am using wireless g. I also ran the Mac internet tuner that seemed to actually increase the speed somewhat.
    I then checked my MBP that is sitting right next to my iMac. I am getting around 15 Mbps down and about 17 Mbps up. I repeated this several times as I did for the iMac. I am surprised at the iMac being so much slower (about 33% slower). I can only assume the hardware in the MBP is better for wireless communication than in the iMac. Can someone explain why this is so?
    thanks,
    Shannon

    Download an app such as Speedtest to your iPad.  Test both ways and see the results for yourself.

  • Speed difference between BT & TT at same address

    I have recently taken advantage of TalkTalk's offer of free broadband on my second line at my home. From TT I am getting approx 2.5MB/s (for free) and from BT 1.5 MB/s according to the speed checker.
    Physically I have two wires entering the house and going down to the same exchange. BT have always maintained that 1.5 would be the highest speed because of the distance to the exchange, how is it then that TT is providing 2.5?
    Speed test gives me this for the BT line
    "IP Profile for your line is - 1500 Kbps"
    Can anyone give me a reason for this and why should I be paying 25 quid per month for a substandard service when the better TT is free??

    richard2010 wrote:
    I have recently taken advantage of TalkTalk's offer of free broadband on my second line at my home. From TT I am getting approx 2.5MB/s (for free) and from BT 1.5 MB/s according to the speed checker.
    Physically I have two wires entering the house and going down to the same exchange. BT have always maintained that 1.5 would be the highest speed because of the distance to the exchange, how is it then that TT is providing 2.5?
    Speed test gives me this for the BT line
    "IP Profile for your line is - 1500 Kbps"
    It may be that you are on adslmax with BT but TT have their own equipment in the exchange and you get an LLU service from them.  You can check your exchange here http://www.samknows.com/broadband/exchange_search
    Can anyone give me a reason for this and why should I be paying 25 quid per month for a substandard service when the better TT is free??
    only you can answer that question
    If you like a post, or want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side of the post.
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

Maybe you are looking for

  • I am getting an Error in CO13 while cancelling conformation

    Dear Gurus ,                      I am getting a error while i am cancelling the Conformation  . I have copied the error message below . Can anybody help me out for the same . Error Message : Confirmed activity must not be smaller than 0 (check entry

  • Report on EWT - Report on tds deducted till issue of tds certificate

    We have implemented ewt recently. we want to have report which will give the tds deducted on advance, invoice , tds challan updation, tds payment, tds certificate issued etc. Do we have any T code which will give the tds details vendor wise for the a

  • "[SSID] 2" seen but not [SSID]

    Hi everyone, I have an issue at an overseas branch office where we are advertising an open SSID. The problem is that users do not see the SSID which we advertise but see "[SSID name] 2" advertised instead. When they connect to this duplicate SSID the

  • Aperture...so far not sure...

    Have 23 days left on my trial... So far I am not impressed... It is very slow...I have very good Memory and storage.. Why is it that iPhoto, seems sooo much easier and faster... Sure aperture has some nice features, but for those of us that take hund

  • Can't open JAR files - tried everything

    Hi guys. So, I have this problem that I can' open .jar files. I'm getting this: "Java JAR-file could not start" I have literally tried EVERYTHING. This is what I have tried: Uninstall, reinstall, restart Mac between every installation, have newest Ja