Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Tips and tricks ➜ is (a|b|c...) better than single triggers?

is (a|b|c...) better than single triggers?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Pompey1   (12 posts)  Bio
Date Mon 02 Jun 2008 09:10 PM (UTC)

Amended on Mon 02 Jun 2008 10:31 PM (UTC) by Pompey1

Message
I think the subject says it all.

From a performance viewpoint, does anyone have an opinion on whether a single large regexp with multiple words / phrases in an or condition is more or less efficient than multiple single word / phrase triggers?

I'm thinking mainly of highlighting words / phrases, but this might extend to other issues eg sending chats / channels to a separate chat window.

Pompey1
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #1 on Mon 02 Jun 2008 09:16 PM (UTC)
Message
Hard to say. It depends on the amount of backtracking going on and the complexity of the regular expression.

However, you don't need to worry about it. I have worlds with over 2500 triggers in them (average of 1800 enabled), all regular expressions, and the most noticable slowdowns are when I omit-from-output and echo stuff to replace it. Of course, that's how it feels - it may not be where my particular bottleneck really is.

Use whatever you like most.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #2 on Mon 02 Jun 2008 10:08 PM (UTC)
Message
This issue came up a while ago:

http://www.gammon.com.au/forum/?id=7898

For a start, version 4.07 of MUSHclient or earlier crashed with a very long list of alternatives. Once you have version 4.08 or higher you are OK in that respect.

The developer of PCRE (the regular expression parser) advised that very long lists of alternatives were "inefficient", however as Worstje says, the performance may well be acceptable.

Breaking this into multiple triggers however does not, I think, improve efficiency, because you are now making MUSHclient do multiple trigger evaluations. In particular, if the word you want to highlight is matched in the first trigger, and you have 100 more triggers, then it will blindly go ahead and attempt to match those too.

For issues like highlighting words in another colour, you are probably best off with one long trigger.

For other things, like chat channels, it is probably more efficient to simply match on "a word" (any word), and then look that word up in a Lua table (in a script). Doing a table lookup will be more efficient than a linear scan of names. Having said that, I doubt you would have enough chat channels for the difference to be noticeable.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,110 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.