960 s1 7.071 microseconds per iteration s2 6.494 microseconds per iteration s3 6.612 microseconds per iteration s4 6.349 microseconds per iteration s5 95.787 microseconds per iteration s6 6.325 microseconds per iteration s7 38.116 microseconds per iteration
wrong # args: should be "exit code"
    while executing
"exit"
    (in namespace eval "::request" script line 51)
    invoked from within
"namespace eval ::request $script"
    ("::try" body line 12)

OUTPUT BUFFER:

#!/usr/local/bin/tclsh # # Test rapidite pour compter le nombre d'occurences # d'un caractere donne dans une string # proc s1 {a b} { return [regsub -all $b $a "" tmp] } proc s2 {a b} { set l1 [string length $a] return [expr {$l1 - [string length [string map [list $b ""] $a]]}] } proc s3 {a b} { return [regsub -all -- $b $a "" tmp] } proc s4 {a b} { return [expr {[string length $a] - [string length [string map [list $b ""] $a]]}] } proc s5 {a b} { return [regexp -all ***=$b $a] } proc s6 {a b} { return [regsub -all "$b" $a "" tmp] } proc s7 {a b} { set count [llength [split [string map [list $b \uFFFF] $a] \uFFFF]] return [incr count -1] } set a "SDERUIOS...SFD..SDZZSER.SDFZRZER" set a [string repeat $a 30] puts "[string length $a]" puts "s1 [time {s1 $a S} 1000]" puts "s2 [time {s2 $a S} 1000]" puts "s3 [time {s3 $a S} 1000]" puts "s4 [time {s4 $a S} 1000]" puts "s5 [time {s5 $a S} 1000]" puts "s6 [time {s6 $a S} 1000]" puts "s7 [time {s7 $a S} 1000]" puts "" exit