Re: Tcl faster than Perl/Python...but only with tricks...



Hello

If you want a speed boost, make sure that the channel is configured to
use -translation binary and use [read].

But [read] has the disadvantage that you can not read line by line, or do I
miss something here?

And I just tried to set translation to binary, and it slowed things down. Am
I doing this wrong or is there something strange happening?

---
proc grep {} {
set f [open bigfile r]
fconfigure $f -translation binary
while { [gets $f line] >= 0} {
if {[string match -nocase "*destroy*" $line]} {
puts $line
}
}
}
---

With the fconfigure the script runs 0.769s and when removing the fconfigure,
the script runs 0.703s...

That turns off a lot of
processing that would otherwise slow things down. Also, if your file is
only a few percent of your available physical address space in size,
then slurping it all into memory is best anyway. :-)

Yes, that was of course the solution I finally came up with, but this
doesn't work of course, when files get really big.

Regards
Stephan
.



Relevant Pages

  • Re: Win32 serial port access
    ... Serial non-blocking read/write works fine with recent Tcl-versions ... fconfigure $s -mode "19200,n,8,1" ... Using TeraTerm connected to COM3 I see that the Tcl script has written ... proc readMe chan { ...
    (comp.lang.tcl)
  • Re: Win32 serial port access
    ... fconfigure $s -mode "19200,n,8,1" ... Using TeraTerm connected to COM3 I see that the Tcl script has written ... proc readMe chan { ... Setting the mode of the serial port fixes the problem. ...
    (comp.lang.tcl)
  • Keep socket connections open
    ... I would like to run a TCL script that goes out and opens a socket ... fconfigure $sock1 -buffering line -blocking false ... puts $sock1 "show ip int bri" ...
    (comp.lang.tcl)
  • Keep socket connections open
    ... I would like to run a TCL script that goes out and opens a socket ... fconfigure $sock1 -buffering line -blocking false ... puts $sock1 "show ip int bri" ...
    (comp.lang.tcl)