This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Old posts that have not been replied to for several years.
Dedan
Master
Posts: 260 Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis
Post
by Dedan » Mon Nov 15, 2004 12:38 pm
I have no way of testing the speed of these commands.
does anyone have the time and means to test this for me?
Code: Select all
set e "entry"
proc test_speed {text} {
global e
if {[string match -nocase "*$e*" "$text"]} {
if {[regexp -nocase {$e} $text]} {
}
thanks for any help given
I once was an intelligent young man, now i am old and i can not remember who i was.
demond
Revered One
Posts: 3073 Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:
Post
by demond » Mon Nov 15, 2004 12:48 pm
Dedan wrote: I have no way of testing the speed of these commands.
yes you have
it's called
time
Dedan
Master
Posts: 260 Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis
Post
by Dedan » Mon Nov 15, 2004 1:27 pm
does this sound right to you?
[11:28] < Isa >. stringmatching is 25 microseconds per iteration : Notice
[11:28] < Isa >. regexping is 21721 microseconds per iteration : Notice
i thought regexp would be much faster
Code: Select all
set e "entry"
bind pubm -|- * test_speed
proc test_speed {nick uhost handle chan text} {
global e
set stringmatch [time {string match -nocase "*$e*" "$text"} 1]
set regexping [time {regexp -nocase {$e} $text} 1]
putquick "NOTICE $nick :stringmatching is $stringmatch"
putquick "NOTICE $nick :regexping is $regexping"
}
I once was an intelligent young man, now i am old and i can not remember who i was.
demond
Revered One
Posts: 3073 Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:
Post
by demond » Mon Nov 15, 2004 2:17 pm
your repetition count of 1 screws the results, but yes, generally [string match] is always faster than [regexp] since the code it translates to is much more simple and optimized
more accurate results:
Code: Select all
[demond@whitepine demond]$ tclsh8.4
% set a blah
blah
% time {regexp -nocase $a skldjfsdfblah290387423890} 1000
7 microseconds per iteration
% time {string match -nocase *${a}* skldjfsdfblah290387423890} 1000
2 microseconds per iteration