Re: good to know: tcl static "regexp" is faster than tcl "string" operation

Liste des GroupesRevenir à cl tcl 
Sujet : Re: 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, 19:33:41
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vl1de5$2bnb8$2@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
....
 But neither is quite as fast as string match (athough regex is close):
 $ cat time-check.tcl
#!/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
   }
}
 proc test-3 { val } {
   return [string match ::* $val]
}
 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]
puts 5=[time {test-3 ::otto} $num]
puts 6=[time {test-3 otto}   $num]
 $ ./time-check.tcl
1=0.45252 microseconds per iteration
2=0.42354 microseconds per iteration
3=0.58949 microseconds per iteration
4=0.58363 microseconds per iteration
5=0.4351 microseconds per iteration
6=0.41378 microseconds per iteration
interesting
1) tcl with debug on
[debug].../NHI1> ./sbin/tcl-time-check.tcl
1=1.07665 microseconds per iteration
2=1.04722 microseconds per iteration
3=1.34974 microseconds per iteration
4=1.34743 microseconds per iteration
5=1.07671 microseconds per iteration
6=1.04552 microseconds per iteration
2) tcl with "production" switch on
[release].../NHI1> ./sbin/tcl-time-check.tcl
1=0.32721 microseconds per iteration
2=0.31452 microseconds per iteration
3=0.4352 microseconds per iteration
4=0.43953 microseconds per iteration
5=0.32741 microseconds per iteration
6=0.31617 microseconds per iteration
there is NO difference between "regexp" and "string match" for
→ Intel(R) Xeon(R) CPU E3-1275 V2 @ 3.50GHz

Date Sujet#  Auteur
31 Dec 24 * good to know: tcl static "regexp" is faster than tcl "string" operation6aotto1968
31 Dec 24 `* Re: good to know: tcl static "regexp" is faster than tcl "string" operation5Rich
31 Dec 24  +- Re: good to know: tcl static "regexp" is faster than tcl "string" operation1aotto1968
31 Dec 24  `* Re: good to know: tcl static "regexp" is faster than tcl "string" operation3aotto1968
2 Jan 25   `* Re: good to know: tcl static "regexp" is faster than tcl "string" operation2eric
2 Jan 25    `- Re: good to know: tcl static "regexp" is faster than tcl "string" operation1aotto1968

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal