You'd put the
var %start.time $ticksqpc
right after the ON RAWMODE, and you'd sprinkle the echoes to the status window at various lines, where hopefully you'd narrow down where the long interval is located. But by 'freeze' you mean the client completely locks up so that ctrl+break doesn't work? I don't see anything here that should do that. But first, your code doesn't do what you want it to do, so it's back to the drawing board, and hopefully you remember who it was.

When you're trying to get code to work, you should have echoes to status window showing what values are being filled into variables, etc, and your while() can be spread across several rows. Then when you get the code working, you can take out the -s switches from var statements, the echoes, and can consolidate the code to fewer lines.

But again, you didn't address the fact that your code reports as if all affected nicks are affected by all of the modes being present.

But in addition to those false positives, it's going to have false negatives in some situations. For example, here's one that won't get reported because it doesn't contain the +I or +e strings you're looking for:

/mode #channelname +vIe nick1 mask1 mask2

You can verify from channel central that the exempt list (not excempted) and invite list are both affected, but there's no +I or +e present. Your script is going to need to do like some of these pushmode scripts do, which is to walk through each character of $1 to identify whether + or - is in effect when it reaches each letter, and there's a corresponding pointer through $2- to identify which 'word' matches each switch letter. Also note that + is implied, so the next command is the same as if +Ie were used.

/mode #channelname Ie mask1 mask2

Also, you can have masks affecting a nick without it matching your search for a token that wild-matches *!*@*, as the following are both equivalents, and your code doesn't see the 2nd one containing +e, and doesn't see it containing any wildmasks:

/mode #channelname e nick1
/mode #channelname +e nick1!*@*