Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: e61de021fe4bd47a4d3dfb33acbb9bbda8ca9034
Ticket: 2992970fffffffffffffffffffffffffffffffff
Slow performance of [append]
User & Date: jgodfrey on 2010-04-28 20:10:57
Changes

  1. icomment:
    > Use [binary format a130 \0] to get that.
    
    Donal - thanks.  As you may have guessed, I don't do much work with binary data... ;^)
    
    > Let's see what you get in terms of timings with [binary format] instead of
    [string repeat]
    
    Alex,
    
    Here's my modified proc using [binary format]...
    
    proc ap {} {
        global sample
        set z [binary format a130 \0]
        for {set i 0} {$i<10000} {incr i} {
            foreach l $sample {
                append buffer [string range $z 0 $l]
            }
        }
        puts "Total size: [string length $buffer]"
    }
    
    Note that I changed the original 100000 to 10000.  Using the original value, 8.5 (fairly quickly) generates a fatal "unable to realloc 485000018 bytes" message. While 8.6b1.1 didn't crash, it also never completed in the 20 mins I let it run.
    
    Reducing the value to 10000, both complete and I see speed differences in the ballpark of what I originally reported (actually, worse).
    
    Total size: 24250000
    1071639 microseconds per iteration
    (Temp) 1 % set tk_patchLevel
    8.5.8
    
    Total size: 24250000
    42250394 microseconds per iteration
    (Temp) 1 % set tk_patchLevel
    8.6b1.1
    
    So, nearly a 40x difference.
    
    
    
    
    
    
    
  2. login: "jgodfrey"
  3. mimetype: "text/plain"
  4. username: "jgodfrey"