GetTriggerInfo Issue

Posted by Candido on Sun 15 May 2011 08:22 PM — 4 posts, 22,708 views.

USA #0
Hello. I'm currently trying to optimize my Mushclient worlds by cracking down on the most time intensive triggers. I wrote a simple script to go through GetTriggerList() and divide GetTriggerInfo(x, 37), which is total time taken to match, by GetTriggerInfo(x, 38), the total number of attempts to match. This would give me the average time each trigger takes on each attempt, and I can just compare to find the worst.

However I started noticing some strange behavior, which is either a bug in Mushclient or a misunderstanding on my part. The triggers that floated to the top of my list claimed to have only attempted to match one time, yet their number of successful matches (trigger info 21) is higher than one. On any normal trigger this is impossible because an increment to 21 will also result in an increment to 38.

Luckily, it was easy to see what these 'one match' triggers had in common, which is that they all had expand variables checked and matched a variable in their regex, like @target.

What do you think?
USA #1
I think I know exactly what you're talking about. When you have "Expand variables" checked, the trigger's regexp is recompiled and its total execution time is copied over. [1] The trigger itself contains the count of successful matches [2], while the regexp object contains the count of attempts [3]. What's happening is that the count of attempts isn't being copied over to the newly-compiled regexp, and the count of successful matches remains because it's in the trigger, not the regexp.


[1]: https://github.com/nickgammon/mushclient/blob/master/evaluate.cpp#L355-387
[2]: https://github.com/nickgammon/mushclient/blob/master/OtherTypes.h#L566
[3]: https://github.com/nickgammon/mushclient/blob/master/regexp.h#L51
Amended on Sun 15 May 2011 09:07 PM by Twisol
Australia Forum Administrator #2
Twisol is quite right. The time was saved but not the number of match attempts. Fixed in version 4.74.
USA #3
Awesome. Thanks!