[jawsscripts] Re: Resizing arrays

  • From: "Octavian Rasnita" <orasnita@xxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Fri, 6 Jan 2012 18:41:48 +0200

I created a dll file that works as a com server that can translate text with 
Google Translate which can be accessed with a certain hot key, and Jaws gets 
the current word or the selected text, executes a script that calls the COM 
object, which prepares the text to send to Google, sends a request to the 
server, waits for Google Translate to parse the request and do the translation, 
encodes the result as JSON, sends the 
result back to the computer, which parses the JSON and gets the translation and 
gives it back to JAWS, and all these things are usually almost instantaineous, 
which means in less than a second).
And the COM object is made in Perl, which is fast, but not as fast as C or 
C++...
So I think the call to the COM object doesn't take too much in these conditions.

Octavian

----- Original Message ----- 
From: "Andrew Hart" <ahart@xxxxxxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Friday, January 06, 2012 4:29 PM
Subject: [jawsscripts] Re: Resizing arrays


> Agreed.  I was merely offering an explanation for the performance
> difference observed.  It was not my intention to disparage the use of
> COM.  Hopefully no one else took it that way.
> 
> Cheers,
> Andrew.
> 
> 
> On 6/01/2012 8:47 AM, Jamal Mazrui wrote:
>> I agree that many consecutive COM calls, e.g., in a loop, can have a
>> noticeable effect on performance.  In my opinion, however, such
>> performance degradation is usually not noticeable in screen reader
>> scripting scenarios.  I am not saying that there are not occasions where
>> this is a concern, but for the most part, the delays of user interface
>> events and speech make COM delays negligible by comparison.
>> 
>> In addition, the benefits of powerful COM techniques should also be
>> weighed.  The .NET ArrayList, for example, provides all the flexibility
>> and dynamism that the original message on this topic was seeking. 
>> Elements of any data type may be added or removed from an ArrayList with
>> ease via dedicated, well-tested methods.  The list may be easily sorted,
>> reversed, or searched by other methods.
>> 
>> One could take the time to write a lot of custom JAWS functions that try
>> to achieve this functionality, and it would be time consuming,
>> error-prone, and still short of the same functionality.  One of the
>> strengths of Windows compared to other platforms is the many, built-in
>> object models that COM clients in any language can exploit.  I agree
>> with the philosophy from the Python programming world:  code to solve a
>> problem first, and then only optimize later if demonstrably needed for
>> performance.
>> 
>> Jamal
>> 
>> On 1/5/2012 2:59 PM, Andrew Hart wrote:
>>> COM object calls are generally more expensive than calls to routines
>>> internal to an application.  There's all the overhead involved in
>>> marshalling cross-process references and the like to deal with.
>>> consequently, if you have to make lots and lots of COM calls, the COM
>>> overhead will become apparent.  I expect this is what you were
>>> observing.  the same is true of out-of-proc servers.  Inproc servers
>>> should suffer less, since they are loaded directly into the address
>>> space of the calling process and hence calls are straight forward, but
>>> unfortunately, JAWS Script doesn't know how to talk to dll's directly,
>>> only COM automation objects.
>>>
>>> Cheers,
>>> Andrew.
>>>
>>> On 5/01/2012 6:12 PM, Doug Lee wrote:
>>>> I got quite a shock a couple months or so ago on the subject of using
>>>> COM objects versus collections, and I assume my results would apply
>>>> reasonably equally to JAWS arrays when compared to COM objects.
>>>>
>>>> Unfortunately I remember niether specific results nor the location of
>>>> any written copy of them, but I do remember finding that tests
>>>> involving over 500 references to a collection versus a COM object,
>>>> Scripting.Dictionary in my case, produced such wildly different
>>>> performance results to indicate clearly in favor of collections over
>>>> COM objects. People have been saying this for years, but honestly, I
>>>> didn't think it was a big enough deal until I did those tests. It
>>>> would be handy for me if someone out there could prove me wrong,
>>>> because I have a lot of code that uses Scripting.Dictionary, predating
>>>> collections of course. But I currently operate with the assumption
>>>> that Scripting.Dictionary objects are costly enough to avoid for loops
>>>> that run, say, more than 50 times.
>>>>
>>>> On Thu, Jan 05, 2012 at 04:05:27PM -0500, Jamal Mazrui wrote:
>>>> Another approach is to use the ArrayList class of the .NET Framework,
>>>> which a JAWS script can access via COM.  Almost any Windows computer
>>>> these
>>>> days has at least .NET 2.0, which includes this class.  The progID to
>>>> pass
>>>> to the CreateObject function is "System.Collections.ArrayList."  The
>>>> methods and properties of the object thus instantiated are documented at
>>>>
>>>> http://msdn.microsoft.com/en-us/library/system.collections.arraylist.aspx
>>>>
>>>>
>>>> This approach has the advantage of working with any JAWS version.
>>>>
>>>> Similarly, for dictionary as opposed to list collections, it may be
>>>> worth
>>>> considering use of the Scripting.Dictionary class of the Windows Script
>>>> Host, available on any Windows computer.  The progID is
>>>> "Scripting.Dictionary."  Such an object is documented at
>>>>
>>>> http://msdn.microsoft.com/en-us/library/x4k5wbx4(VS.85).aspx
>>>>
>>>> A couple more useful web pages on this topic are as follows:
>>>>
>>>> http://www.robvanderwoude.com/vbstech_data_arraylist.php
>>>>
>>>> http://halfloaded.com/blog/net-classes-within-vbscript-doing-randomness-and-arrays-the-easy-way/
>>>>
>>>>
>>>> Jamal
>>>>
>>>> __________???
>>>>
>>>> View the list's information and change your settings at
>>>> //www.freelists.org/list/jawsscripts
>>>>
>>>
>>> __________�
>>>
>>> View the list's information and change your settings at
>>> //www.freelists.org/list/jawsscripts
>>>
>> 
>> 
> 
> 
> __________�
> 
> View the list's information and change your settings at 
> //www.freelists.org/list/jawsscripts
>
__________�

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

Other related posts: