On 2/11/06, Seth Willits <[EMAIL PROTECTED]> wrote:
> On Feb 10, 2006, at 9:34 PM, Seth Willits wrote:
>
> > 5 minutes and 38 seconds in 2006r1.
> >
> > 5 *seconds* in 5.5.5.
>
> Aha! I should have waited just 3 more minutes to send that email.
> It's the Trim function that's slow. If I simply return line instead
> of Trim(line) it's 68 times faster.

I investigated this a bit more...

It depends on the encoding as well. I've run some tests with diffent encodings:

This is the timing with RB 5.5.5 on a Mac:

  4ms ('nil' encoding, RB's Trim)
  2ms (macintosh, RB's Trim)
  5ms (windows-1252, RB's Trim)
  4ms (UTF-8, RB's Trim)
  1942ms (UTF-16, RB's Trim)

As you can see, UTF-16 was the only one really bad here.

Now the timings with RB 2006r1:

  1ms ('nil' encoding, RB's Trim)
  469ms (macintosh, RB's Trim)
  715ms (windows-1252, RB's Trim)
  7ms (UTF-8, RB's Trim)
  6ms (UTF-16, RB's Trim)

Apparently, someone has optimized UTF-16 but messed it up for some others.

Now, before somenone says that the slowdown was perhaps necessary
because the former version was not encoding-savvy with "macintosh" and
"windows" encodings:

I've written my own "FastTrim" method that simply looks at the start
and end of a string (encoding-savvy) and here are the results I get
with it:

  15ms ('nil' encoding, FastTrim)
  29ms (macintosh, FastTrim)
  43ms (windows-1252, FastTrim)
  56ms (UTF-8, FastTrim)
  25ms (UTF-16, FastTrim)

So, while having an initial overhead, it does not get slower with any
of the more complicated encodings.

Here is a test project, including my RB-written FastTrim method that
helps in some of these bad cases pretty well:

<http://www.tempel.org/ftp/pub/REALbasic/FasterTrim.rbp.zip>

--
Thomas Tempelmann - exaggerating over a million times a day!
http://www.tempel.org/rb/  -- The primary source of outdated REALbasic
plugins and examples
Skype: tempel.org   AIM: superTempel
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to