Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Meylot
Newbie


Joined: 20 Jun 2007
Posts: 5
Location: Somewhere in Middle Europa

PostPosted: Sat Jun 23, 2007 9:06 am   

cMUD patterns or regexp
 
I've tested the time of text matching in two ways: by the cMUD's pattern and perl regexp
Using
#IF (text=~pattern)
turned out to be between a few and more than 10 times faster than
#IF (%regex(text,pattern))

What is the reason of that, and does it mean, that using cMUD patterns instead of perl regexp patterns in triggers gives better time performance? (with appreciable difference)
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Sat Jun 23, 2007 5:02 pm   
 
All CMud patterns are converted into regex in the background... the difference you're seeing is likely due to WHAT pattern it's been converted into... some patterns take less processing time than others and from what I can tell, the CMud format doesn't use very complex regex patterns when it converts.
_________________
If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :)
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sat Jun 23, 2007 5:30 pm   
 
Recall that cMUD pattern is already optimized by the application and is likely to be processed faster that way. With the latter you have the overhead of the function call and the probability that this pattern needs to be compiled when it hits the underlying Perl Regex library.

Zugg is likely is the only one who can answer this definitively.
_________________
Asati di tempari!
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Jun 25, 2007 5:48 pm   
 
Yes, the (test=~pattern) is always going to be faster. The %regex version has the overhead of a function call, whereas the =~ operator is handled within the compiler itself.
Reply with quote
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Mon Jun 25, 2007 7:09 pm   
 
How about adding the syntax (test =~ /regexp/) to allow for regexp comparisons without using the function?
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Jun 25, 2007 7:30 pm   
 
The parser won't handle strings delimited by characters other than "", so it's not an easy change unfortunately. I'll consider that in the future, but for now you should just try to use normal patterns instead of regexp.
Reply with quote
Zhiroc
Adept


Joined: 04 Feb 2005
Posts: 246

PostPosted: Mon Jun 25, 2007 8:28 pm   
 
I find I use many more regexps than simple patterns. On the other hand, I rarely use pattern matching in #IF's anyways... Another suggestion would be to create a new pattern wildcard that means "Use a regexp from here". So you could do something line (test =~ "%/regexp") to do this within the rules of your lexer.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net