Question on Statistics/Metrics

Posted by WillFa on Fri 16 Jul 2010 12:29 AM — 4 posts, 17,817 views.

USA #0
Nick,

Do the stats displayed in the lower right corner of the trigger edit windows reflect the time it took the RegEx engine to match the pattern, or the time to match and execute the script and finalize the trig?



Oh, and is there a way to get similar stats about a plugin?
Amended on Fri 16 Jul 2010 12:30 AM by WillFa
USA #1
WillFa said:
Nick,

Not Nick, but I do have a copy of the source in front of me. >_>

WillFa said:
Do the stats displayed in the lower right corner of the trigger edit windows reflect the time it took the RegEx engine to match the pattern, or the time to match and execute the script and finalize the trig?

Looks like it's the time it took to match the pattern. Here's how it looks in my fork. I heavily refactored the regular expression class, but it should work the same, and I barely touched the code in this particular section anyways. At any rate:

  LARGE_INTEGER start;
  if (App.m_iCounterFrequency)
    QueryPerformanceCounter (&start);

  int options = App.m_bRegexpMatchEmpty ? 0 : PCRE_NOTEMPTY; // don't match on an empty string
  pcre_callout = NULL; // un-set the global pcre_callout() function pointer
  int count = pcre_exec(
      this->m_program, this->m_extra,
      string, strlen (string), start_offset,
      options, &offsets[0], offsets.size()
      );

  if (App.m_iCounterFrequency)
    {
    LARGE_INTEGER finish;
    QueryPerformanceCounter (&finish);
    this->iTimeTaken += finish.QuadPart - start.QuadPart;
    }


WillFa said:
Oh, and is there a way to get similar stats about a plugin?

I believe it's exposed through GetTriggerInfo. There's also a GetPluginTriggerInfo for externally getting at it. Selector 20 for the script invocation count, and 21 for times matched. I can't find a total-time-taken selector, oddly.

EDIT: Yeah, not seeing the time taken accessed anywhere visible from a script, so chances are good that it's not accessible currently.
Amended on Fri 16 Jul 2010 01:11 AM by Twisol
Australia Forum Administrator #2
The stats shown on the trigger edit window are the time taken for the regular expression to match (or not). It excludes the time taken to do something if it matches.

There is no present way of finding the time taken in plugins, however I have just added new selectors to GetTriggerInfo and GetAliasInfo (release 4.53) which lets you query that (and GetPluginTriggerInfo and GetPluginAliasInfo).
Australia Forum Administrator #3
I also note it doesn't tell you how many times it attempts to match, so I added a couple more selectors to do that. So now you could find the average time-to-match by dividing one by the other.

For lines from the MUD, an *attempt* to match will be made for every line, unless a preceding trigger in the trigger sequence already matched, and did not have "keep evaluating" set.

This could be useful to see whether your triggers or aliases are slowing down execution significantly.