Performance speed and scripting

Posted by Gore on Mon 09 Feb 2004 03:19 AM — 7 posts, 23,355 views.

#0
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.
#1
Sorry ignore, the first four lines on the second quote.. heh
Australia Forum Administrator #2
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.
#3
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*
Australia Forum Administrator #4
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.
Russia #5
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?
Australia Forum Administrator #6
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.