Posted to tcl by colin at Wed May 23 06:01:30 GMT 2012view pretty

package require Thread

proc doit {head} {
    puts stderr $head
    puts stderr THREAD:[time {::thread::create {proc test {} {}; thread::exit}} 100]
    puts stderr INTERP:[time {::interp create test; interp delete test} 100]
    puts stderr PROC:[time {proc test {} {}; rename test {}} 100]

    set thread [::thread::create {proc test {} {}; thread::wait}]
    puts stderr E_THREAD:[time {::thread::send $thread test} 100]

    interp create I; interp eval I {proc test {} {}}
    puts stderr E_INTERP:[time {::interp eval I test} 100]
    interp delete I

    proc test {} {}
    puts stderr E_PROC:[time {test} 100]

    set now [clock microseconds]
    puts stderr A_THREAD:[time {::thread::send -async $thread test indicator} [set counter 100]]
    while {$counter} {vwait indicator; incr counter -1}
    puts stderr AE_THREAD:[expr {[clock microseconds] - $now}]
}

doit "Out of the Box"

load ../InitScript/linux-ix86/InitScript.so
#package require InitScript
set script [InitScript {proc tclInit {} {}}]
puts stderr $script

doit "With \[proc tclInit {} {}\]"

set script [InitScript {proc tclInit {} {incr ::THC}}]
puts stderr $script

doit "With \[proc tclInit {} {incr ::THC}\]"