> Hi - I published the ns_share results, but it was a looong
> time ago, like a few years ago when we upgraded from 2.X to
> 3.X.  I found this quote in my mailbox around November 9,
> 2002 from the mailing list:
>
>   "The test I ran to compare 8x with 7.6x was a 10-line loop, around 400K
>   iterations, setting 2 ns_share arrays.  Because of TCL 8x compilation,
>   I expected it to go faster, but instead, it was around 3x slower.  That
>   doesn't mean our site will be 3x slower of course, but it didn't encourage
>   me to jump on the 8x bandwagon - that's all."

>   ns_share rlidarray
>   set fd [open "textfile" r+]   ;# a file of 32-char, fixed-length strings
>   set recno 0
>   while {[gets $fd s] == 32} {
>     set idname [string trimleft [string range $s 0 24] " "]
>     set rlidarray($idname,RECNO) $recno
>     incr recno
>   }
>   if {[string compare $s "**EOF**"] != 0} {
>     error "rlinitid: Missing EOF string in idfile"
>   }

I would *not* expect this code to gain any speed.  The main mantra
of Tcl programming for performance is to use procs.  Code in the
toplevel namespace is *not* compiled, which includes that 'while'
loop above.  The philosophy is that it will only get run once,
which is sort of a trip-up since 'while' runs "once", but of course
iterates many times for itself.  Try this instead:

proc run {textfile} {
  ns_share rlidarray
  set fd [open $textfile r+]
  set recno 0
  while {[gets $fd s] == 32} {
    set idname [string trimleft [string range $s 0 24] " "]
    set rlidarray($idname,RECNO) $recno
    incr recno
  }
  if {[string compare $s "**EOF**"] != 0} {
    error "rlinitid: Missing EOF string in idfile"
  }
}
run $textfile

My guess is you would see a healthy speedup.  There are other ways
to speed up the above code, but I understand that you are comparing
the exact same code, so I'll leave it alone.

Jeff


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to