Skip to content
Tcl Source Code View Ticket
Login

View Ticket

iterating with regexp over many expr performance problem

Closed / Invalid853845ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2003-12-04 05:43:27
Can anyone confirm a bug or a feature :-)

When looping over 30 regular expressions like

foreach exp $expList {
  if {[regexp $exp "string"]} then {
    set x 1
  }
}

performs well, but when 31 expressions are used, the
performance is
considerably slower.

I have included a file that results in

407 microseconds per iteration
3094 microseconds per iteration

Quite a change for adding only 1 more expression.
dkfplain2003-12-04 16:21:34
Logged In: YES 
user_id=79902

No file attached.  Remember to check the box as well as
specifying the filename...  :^/

(Also, which exact version of Tcl are you using?  [info
patchlevel] will tell you.  Thanks!)
hobbs Closed ticket [853845ffff]. [History diff]2003-12-05 00:57:36
hobbsplain2003-12-05 00:57:37
Logged In: YES 
user_id=72656

30 is the exact number of locally cached REs in the Tcl
core, so this is expected.  Why one would look over so many
is the real question.  Tcl does also cache REs in objects,
so repeeat RE use of the object should not be slow.  Always
do such things in a proc though, as toplevel loops don't get
byte-compiled.
hobbs Ticket [853845ffff]: 2 changes [History diff]2003-12-05 00:57:38
nobodyplain2004-05-07 08:54:05
Logged In: NO 

test
Log in (anonymous is fine) to add a comment.