Ok. Last week I have been trying to catch up the parsing speed of MCP.
Using the 10155 Ragnarnos fight event data set from MCP,
the 'core parsing function' of MCP takes 0.5 ~ 0.6s. ParserLib now takes 0.6~0.85s.
To further increase ParserLib's speed I've added the cocept of a "Parsing Optimizer", which can further reduces ParserLib parsing time to 0.6 ~ 0.7, which is almost the same as fast as MCP.
The optimizer actually is just a set of pattern - keyword , such as the keyword 'gain' in AURAADDEDSELFHELPFUL (You gain %s.), so the optimizer looks like this:
ParserLibOptomizer = {
AURAREMOVEDOTHER = "fade",
AURAREMOVEDSELF = "fade",
COMBATHITCRITOTHEROTHER = "crit",
......
}
The optimizer is completely optional, so when you don't have an optimizer on your language, ParsreLib still works fine, just that it'll be slower by may be 20%. But at the same it doesnt have to load that table into memory so memory usage is lower, basically that's a simple time-space trade off.
---
Finally I've found that the biggest bottleneck for speed is
CompostLib, the above timing does not take CompostLib into account. When CompostLib is used (recycling the tables), the parsing speed increases from 0.6s to 1s, and the compost:Recycle() is responsible for about 0.3~0.4s of the time.
That's a big trade off betwen time and space. But I think I'll just stick with using CompostLib, because on real time, the speed will not make a actual noticeable difference; but when garbage collection occurs, you might notice a slight delay on your WoW client.
---
At last I have added Deformat(text, pattern) into the library, so when you want to parse for a custom pattern which is not supported by ParserLib, you can just call Deformat like this:
spell, target =
parsereformat("Shield fades from Rophy.", AURAREMOVEDOTHER)
ParserLib's Deformat doesn't support trailers though, I think all patterns with possible trailers are already supported by ParserLib so don't bother adding that part.
I'm gonna do some final clean up on the codes, and then I'll submit ParserLib itself to WoWInterface. If you have any question or suggestion please leave a message here.