Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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.
Entire forum
➜ MUSHclient
➜ Lua
➜ Will a variable list slow down triggers?
Will a variable list slow down triggers?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Thalir
(13 posts) Bio
|
Date
| Fri 03 Aug 2007 06:35 AM (UTC) Amended on Fri 03 Aug 2007 07:51 AM (UTC) by Thalir
|
Message
| If I have a variable listing names (e.g. apple|banana|orange...), and a trigger that highlights these names when they appear on the mud:
Will having to match against this list, slow things down for my other triggers (e.g. attack messages), since every word is matched against the list? If so, is there a better way around this?
<triggers>
<trigger
custom_colour="15"
enabled="y"
expand_variables="y"
ignore_case="y"
match="\b(@!words)\b"
regexp="y"
repeat="y"
sequence="50"
>
</trigger>
</triggers>
<variables>
<variable name="words">apple|banana|orange</variable>
</variables>
For a start, I've read somewhere that saving functions into a script and having an alias call that function, is faster than a mushclient alias (with the function written in the box GUI). Something about compilation at the start, which makes sense. So I gather, it's optimum to use plugins and scripts when possible to maintain speed? | Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #1 on Fri 03 Aug 2007 07:51 AM (UTC) |
Message
| Took me a bit, but I finally found an old thread which dealt with this issue almost exactly. If you're just highlighting everything that matches this list, regardless of context, you're certainly going to bog down your computer, as it will be running a small script to match each and every single line. This might not be noticeable depending on the machine and what you're doing, but it can also wreak havoc with your other triggers if they have to gag a line or something. Pretty much, just make sure that your trigger will only fire when it's needed, and not for every single instance possible.
http://www.gammon.com.au/forum/bbshowpost.php?id=7898 |
It is much easier to fight for one's ideals than to live up to them. | Top |
|
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Reply #2 on Fri 03 Aug 2007 11:47 AM (UTC) |
Message
| It will be a bit inefficient, for one thing the regular expression itself has to do a lot of work, plus it has to be compiled every time from the variable. Regular expressions that don't have 'expand variables' checked are compiled once (I think).
Depending on your reason for doing it (in your case you seem to be wanting to colour the words) it can be fiddly to do it other ways.
You could run a bit of a test with the Simulate function to push through test data, and a bit of a timing test. It is probably OK on modern machines, but would in the end be slower than other methods.
The problem is, your example will match on practically every line from the MUD (they will all have words in them), so it will fire on every line.
If you narrow it down a bit (eg. "* enters the room"), then you could look up the wildcard in a table (as shown in the other thread), and then omit the matching line and redisplay it with the word coloured. |
- 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.
13,073 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top