[Javascript] JavaScritpt simple compression code
Paul Novitski
paul at novitskisoftware.com
Fri Feb 18 18:50:03 CST 2005
At 03:59 AM 2/18/2005, Eligio Morgado wrote:
>Finally my code works. But as I expected, it takes lot of time for
>doing the GETs. Sometimes I need to split the original string in 90
>pieces!! Imagine: split, send a part, wait for ASP processing, process
>ASP returning.... and start again... split, send a part....
Eligio,
I would think you could speed up your current process by doing it in
parallel instead of in series. Instead of waiting for each response before
sending the next, why not send them all at once? Divide your big string
into N chunks of 1900 characters, and for each chunk initate a separate
xtmhHTTP request -- all to run concurrently. Each chunk already identifies
itself by its part number, so there's no danger of getting them out of order.
The server is going to execute a new copy of your asp program for each
request, just as though they had come in from N different users.
For each incoming request, the asp program copies the data into the
database. Each database record consists of N subrecords, e.g. three fields
SessionId, PartNo, and Data. It doesn't matter if Part 7 is written before
Part 3. The various parts are concatenated later when they are used for
whatever purpose.
By the way, when the response time problem of concatenation arose earlier
you responded that you understood, but your example was in JavaScript. The
real problem as I understand it is in VBscript. Every time strings are
concatenated, new memory is initialized to hold the result, and garbage
collection is either mediocre or non-existent. Memory is eaten up fast and
the processor labors to copy all that stuff from one place to another.
One way around this is to load incoming string fragments into an
array. When you're ready to combine the fragments, don't use the ampersand
to concatenate, instead use the array function join().
aData(1) = "The turtle"
aData(2) = "swam under the"
aData(3) = "ocean"
sString = join(aData, " ") ' insert a space between each fragment
or
nPart = Request.Querystring("part")
aData(nPart) = Request.Querystring("text")
...
sResult = join(aData, "") ' join fragments with no space between
Paul
More information about the Javascript
mailing list