Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: a78f09bd7a3bc49b9d8521e0cdc5c43c610886734e8c2208e03eda8b3b3c7a2b
Ticket: 28cc67a606a7ab771af4c7b542b34ec1a377edc7
array set from dict: set values multi times on the same array is slower with Tcl9.0.
User & Date: anonymous on 2024-04-15 16:01:42
Changes

  1. comment changed to:
    proc SimplePERM {} {
        set permmod [dict create]
        for {set i 0} {$i < 512} {incr i} {
            dict set permmod $i [expr {$i + int(rand() * (256 - $i))}]
            
        }
        return $permmod
    }
    
    proc generateData {} {
        array set val0 {} ; array set val1 {} ; array set val2 {}
        for {set i 0} {$i <= 20} {incr i} {
            for {set j 0} {$j <= 20} {incr j} {
                for {set k 0} {$k <= 20} {incr k} {
                    set v [SimplePERM]
                    array set val0 $v
                    array set val1 $v
                    array set val2 $v
                }
            }
        }
    }
    
    generateData
    
    time tclsh9.0b2 setarray.tcl
    > 8,23s user 0,02s system 99% cpu 8,281 total
    time tclsh9.0b1 setarray.tcl
    > 7,93s user 0,02s system 99% cpu 7,962 total
    time tclsh8.6.14 setarray.tcl
    > 2,71s user 0,01s system 99% cpu 2,726 total
    
  2. login: "anonymous"
  3. mimetype: "text/plain"