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 ➜ General ➜ Performance speed and scripting

Performance speed and scripting

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


Posted by Gore   (207 posts)  Bio
Date Mon 09 Feb 2004 03:19 AM (UTC)
Message
Regarding scripting and aliases, does anyone know if putting a script in a subroutine, then calling it from an alias or putting the script in the alias is faster? For example..

Would this:

Quote:

Sub En_Aco
   World.send "envenom " & dirk & " with aconite"
End Sub

Sub En_Cur
  World.send "envenom " & dirk & " with curare"
End Sub

Sub Illusion_flay (a,b,wildcard)
  World.Send "conjure illusion Gore flays the sileris coating from you.                                        You apply a sileris berry to yourself."
End Sub

<aliases>
  <alias
   match="dca"
   enabled="y"
   group="attacks"
   send_to="12"
   sequence="100"
  >
  <send>en_aco
en_cur
World.Send &quot;dstab &quot; &amp; target
illusion_flay</send>
  </alias>



or this:

Quote:

en_aco
en_cur
World.Send "dstab " & target
illusion_flay

Sub En_Aco
   World.send "envenom " & dirk & " with aconite"
End Sub

Sub En_Cur
  World.send "envenom " & dirk & " with curare"
End Sub

Sub Illusion_flay (a,b,wildcard)
  World.Send "conjure illusion Gore flays the sileris coating from you.                                        You apply a sileris berry to yourself."
End Sub

Sub dstab_cur_aco (a,b,wildcard)
  en_aco
  en_cur
  World.Send "dstab " & target
  illusion_flay
End Sub

<aliases>
  <alias
   script="dstab_cur_aco"
   match="dca"
   enabled="y"
   group="attacks"
   sequence="100"
  >
  </alias>
</aliases>



Be faster? Or does it not even matter? Thanks for your help on this, I don't exactly have a way to time it.. just wondering if anyone has any opinions.
Top

Posted by Gore   (207 posts)  Bio
Date Reply #1 on Mon 09 Feb 2004 03:20 AM (UTC)
Message
Sorry ignore, the first four lines on the second quote.. heh
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Mon 09 Feb 2004 06:12 AM (UTC)
Message
It is faster (I'm not sure by how much) to put the script into the script file (and not have it directly in the alias).

The reason is compilation time - the script is compiled (checked for errors, comments discarded, etc.) once if in the script file, but every time if it is directly in a trigger/alias/timer.

The difference may be minor for small scripts, but would be noticeable for a lengthy one.

- Nick Gammon

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

Posted by Gore   (207 posts)  Bio
Date Reply #3 on Mon 09 Feb 2004 07:39 AM (UTC)
Message
Nice, thanks a lot Nick, even if it's minor, I run a very very slow computer, and will have a lot going on with mushclient once I've got everything in *g*
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Mon 09 Feb 2004 08:10 PM (UTC)
Message
The other thing you could do on a slow machine, is to identify any triggers that get matched more often than others (eg. a prompt trigger) and give it a lower sequence number (eg. 90) so it matches first. That way, it doesn't spend time matching triggers when it could be matching the common one first.

- Nick Gammon

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

Posted by Ked   Russia  (524 posts)  Bio
Date Reply #5 on Mon 16 Feb 2004 12:09 PM (UTC)
Message
This relates to the topic somewhat, so I decided to ask about it here. I've recently gotten fed up with editing the endless script files that I use everywhere and get to reworking them all into a set of Python modules, putting everything into classes. So far it's been working out quite well, if it wasn't for one small problem: since everything is in a class of its own, I need to refer to methods through a single instance in the main scope of the script file loaded by Mushclient, e.g.:


inst = TestClass()
class TestClass(object):
   def __init__(self):
      pass
   def method1(self, name, output, wildcs):
      pass


but imagine my surprise when I found out that the little Script field in the trigger/alias/timer dialogue won't accept anything like:

inst.method1

I recovered quite fast and just fell back on putting all calls through the 'Send to script' thingy, but sometimes it would still be more convenient to call the method directly. So the question is whether that's somehow possible or can be made possible without much effort?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #6 on Mon 16 Feb 2004 08:26 PM (UTC)
Message
The script field in the triggers etc. is something that is resolved via COM at script compile time - ie. it finds the address of the procedure entry point and stores that.

However what you are asking for is a derived address, one computed by the script itself.

I doubt that can work, even if I changed it to allow the period into the script name.

I don't think there is much difference in effort in putting the script call into the Send box and then doing Send To Script.

- 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.


21,990 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.