Sujet : good to know: tcl static "regexp" is faster than tcl "string" operation De : aotto1968 (at) *nospam* t-online.de (aotto1968) Groupes :comp.lang.tcl Date : 31. Dec 2024, 11:19:34 Autres entêtes Organisation : A noiseless patient Spider Message-ID :<vl0gfm$26irh$1@dont-email.me> User-Agent : Mozilla Thunderbird
#!/usr/bin/env tclsh proc test-1 { val } { if {[regexp ^:: $val]} { return true } else { return false } } proc test-2 { val } { if {[string range $val 0 1] eq "::"} { return true } else { return false } } set num 100000 puts 1=[time {test-1 ::otto} $num] puts 2=[time {test-1 otto} $num] puts 3=[time {test-2 ::otto} $num] puts 4=[time {test-2 otto} $num] > ./sbin/time-check.tcl 1=1.26311 microseconds per iteration 2=1.09152 microseconds per iteration 3=1.44028 microseconds per iteration 4=1.43917 microseconds per iteration
Date
Sujet
#
Auteur
31 Dec 24
good to know: tcl static "regexp" is faster than tcl "string" operation