mIRC Home    About    Download    Register    News    Help

Print Thread
G
GabrieL1
GabrieL1
G
Some rather meaningless regex calls copied and pasted from my script. This problem is causing me to go from 8 fps to 6 fps in a /drawpic script of mine. It's not the same as the timer problem (no timers used).
I got an amazing speed difference of 3+seconds between mIRC 6.16 and 6.17.

Code:
alias regextest {
var %c = 200, %ticks = $ticks, %s = This is a test _ of mIRC RegEx, %re
echo -a This is a test of $ $+ regex in mIRC
while (%c > 0) {
if ($calc(%c / 10) == $int($calc(%c / 10))) echo -a %c
%re = $iif($regex(%s,^-([a-zA-Z]+[0-9]*|[0-9]+)),$gettok($1,1,32))
%re = $iif($regex(%s,^-([a-zA-Z]+[0-9]*|[0-9]+)),$gettok($1,1,32))
%re = $iif($regex(%s,^\+([a-zA-Z]+[0-9]*|[0-9]+)),$gettok($1,1,32))
%re = $iif($regex(%s,^-([a-zA-Z]+[0-9]*|[0-9]+)),$gettok($1,1,32))
%re = $iif($regex(%s,^-([a-zA-Z]+[0-9]*|[0-9]+)),$gettok($1,1,32))
%re = $iif($regex(%s,^-([a-zA-Z]+[0-9]*|[0-9]+)),$gettok($1,1,32))
%re = $iif($regex(%s,^\+([a-zA-Z]+[0-9]*|[0-9]+)),$gettok($1,1,32))
%re = $iif($regex(%s,^-([a-zA-Z]+[0-9]*|[0-9]+)),$gettok($1,1,32))
%re = $regex(%s,([^\s]+)\s?([^_]*(?!_)*)(?:\s?_\s?(.*))?)
%re = $+(Test,_,$regml(1)) $_regsub($regml(2),/\s/g,$chr(1)) $regml(2) $regml(3)
dec %c
}
echo -a Completed $ $+ regex test in $calc(($ticks - %ticks) / 1000) seconds.
echo -a Run this code in both mIRC 6.16 and 6.17 and note the speed difference.
} 

Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
I can't confirm any reduced performance in $regex. I didn't test your script because it is by no means an accurate reflection of $regex's performance. It contains too much irrelevant stuff, like $gettok, /if and $iif, which is notoriously slow. I used this:
Code:
alias regextest {
  var %i = $1, %r = ^-([a-zA-Z]+[0-9]*|[0-9]+), $&
    %s = This is a test _ of mIRC RegEx, %t = $ticks
  while %i { !.echo -q $regex(%s,%r) | dec %i }
  echo -s $calc($ticks - %t)
}

Running /regextest 150000 on 6.16 and 6.17 did show some very small difference (6.17 being slower) but I wasn't convinced that it was the $regex call that made the difference, so I tested with another alias, that measures $regex's actual processing time, as accurately as possible. It does this by running a loop with $regex, then running the exact same loop but without $regex and finally subtracting the duration of the second from the duration of first:
Code:
alias regextest2 {
  var %i = $1, %j = %i, %r = ^-([a-zA-Z]+[0-9]*|[0-9]+), $&
    %s = This is a test _ of mIRC RegEx, %u, %t = $ticks
  while %i { !.echo -q $regex(%s,%r) | dec %i }
  %u = $ticks
  while %j { !.echo -q %s %r | dec %j }
  echo -s $calc(%u * 2 - $ticks - %t)
}

Running /regextest2 100000 a bunch of times on both versions gave these results:

6.16
1046
1079
968
1078
1047


6.17
1016
1047
1124
1125
1046

So my suspicion was confirmed: what got a tiny bit slower is the looping mechanism (variable retrieval seems to perform the same, as I tested all the above by passing the literal strings in $regex too). $regex performance seems to be exactly the same as in 6.16.

These results show something that one needs to keep in mind when comparing the perfomance of things between the two versions: since looping itself has become slower, one has to make up for this in the related benchmarks.

Btw, I tested other regex patterns too, in case that made a difference, but I got the same results

Last edited by qwerty; 03/03/06 02:24 PM.
Joined: Oct 2005
Posts: 1,671
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,671
You mentioned that you noticed the slow-down in a picture window. Khaled said, in one post, that he found a problem in the /draw* commands that was causing them to be slower than they should be. He says the problem has been corrected for the next bugfix release.

-genius_at_work

G
GabrieL1
GabrieL1
G
Well I agree with you that more testing needs to be done. But my code does prove that there's a problem somewhere. I get 0.11 seconds in 6.16, and 3.43 seconds in 6.17 running the same code. That simply just shouldn't be, it's a relatively simple alias, and that's a huge speed difference.
The problem could be with $iif, $calc, or setting temp variables. I can elimate while loops simply because the script routine in which I spotted this problem doesn't use them. When I find time to do so, I'll perform additional tests in order to isolate this problem.
In the mean time, I would strongly suggest that you try my code, as there's a highly noticable difference in processing time, which you can easily see for yourself (although change $1 to %s obviously, I didn't notice that before. Although the results are the same either way.)
And no, the problem isn't related to /drawpic. My routines ran at the exact same speed in 6.16 and 6.17 once I took out the relevant regex calls. And, as you can see, the above code doesn't use /draw commands. I would hazard a guess towards the combination of $regex with $iif, but I will test this later.

I think we can all agree that the code above shouldn't take over 3 seconds longer to process in 6.17, that's a 3118% increase (yes, over three thousand percent longer).


Have a good weekend mirc.com smile

Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Quote:
I think we can all agree that the code above shouldn't take over 3 seconds longer to process in 6.17, that's a 3118% increase (yes, over three thousand percent longer).

It shouldn't take over 3 secs longer, and it doesn't, at least on my computer. For 200 iterations, there is hardly a measurable difference here. So I changed 200 to 5000 in your snippet and I noticed that 6.16 takes around 4100 msecs while 6.17 takes around 4300 msecs to finish. These results seem to agree with my original findings. What's for sure is that there's no 3000% increase in running time or anything of the sort: I only got a 5% increase.

O
Om3n
Om3n
O
No noticable speed differences here either, 0.109seconds for 200 and 2.547 for 5000.

To the original poster, have you tried this same code on clean installs of both 6.16 and 6.17?

Joined: Apr 2004
Posts: 755
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 755
$_regsub ?

it took: 0.311 seconds on .17
and on .16 it took 0.311 seconds

i ran the code 5 times on each and these came up 3 times for each. Slowest value of .411 actualy comming from .16.

I did take out the $_regsub identifier as i have no clue what this custum alias does. This might have something to do with this or not.

Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Ah good catch, I hadn't even noticed that custom identifier there (it would help if the OP mentioned it...). Looks like it could be something like
Code:
alias _regsub var %a | !.echo -q $regsub($1,$2,$3,%a) | return %a

Adding this alias still doesn't alter the results in any way: 6.16 is just a tiny bit faster.

Last edited by qwerty; 04/03/06 10:50 AM.
G
GabrieL1
GabrieL1
G
Quote:
Ah good catch, I hadn't even noticed that custom identifier there (it would help if the OP mentioned it...). Looks like it could be something like
Code:
alias _regsub var %a | !.echo -q $regsub($1,$2,$3,%a) | return %a

Adding this alias still doesn't alter the results in any way: 6.16 is just a tiny bit faster.


And walah, you found the problem. I didn't even think about how I pasted my _regsub function to my clean mIRC copies, silly me. My _regsub function is similiar to the one above, except I was using a ".timer 1 0 unset %a" (not realizing that u can make it a local var when used with $regsub). The timer is what slowed it down in 6.17. So this is the same timer bug that Khaled currently knows about. All that can be said for sure now is that a timer used in my code slows it down about 3000%, hopefully this is fixed soon.
Thanks for helping, and sorry I made an unconfirmed bug report. I'll be more careful in the future.


Link Copied to Clipboard