PtokaX forum

Development Section => Extensions for PtokaX Lua => Topic started by: bluebear on 17 April, 2006, 12:14:37

Title: Lua parsing vs. PxUtilities parser
Post by: bluebear on 17 April, 2006, 12:14:37
A test was made by me and mutor.

2 Lua 5.0.2 scripts, 1 uses pure lua to parse, 1 use PxUtilities.dll to parse.

Both script parsed 5.000.000 $ConnectToMe's

The results:
? Pure lua parsing:
? ? Duration: 34406 ms
? ? 00:00:34.406

? Parsing with PxUtilities:
? ? Duration: 8016 ms
? ? 00:00:08.016

The results shows that parsing DcCommands with PxUtilities is over 4 times faster than plain lua!
Means that I will add the full DC Command parser into this lib, and it should be used by all scripts to parse DC Commands with i think.
Title: Re: Lua parsing vs. PxUtilities parser
Post by: bastya_elvtars on 17 April, 2006, 13:06:35
So does this split up DC commands? Great. Happy Easter then.  ;D
Title: Re: Lua parsing vs. PxUtilities parser
Post by: bluebear on 17 April, 2006, 13:59:34
For a command like $ConnectToMe it will be like this:

invalid, nick, IP, port = Parse.CTM(data)
if invalid then
? ?if invalid == 1 then
? ? ? -- Bad IP (out of range/and such)
? ?elseif invalid == 2 then
? ? ? -- IP is in a local range (eg. 192.168.*.*)
? ?elseif invalid == 3 then
? ? ? -- port number is out of range or otherwise invalid
? ?elseif invalid == 4 then
? ? ? -- Nickname is missing or this was not a $ConnectToMe
? ?end
else
? -- work with data
end

I just did some more speed tests.. On 5000 commands its only twice as fast, on 5.000.000 its 4 times faster, on 50.000.000 its 5 times faster..
The details of what the parser will check will depend on what ptokax already checked it self first...
For example, if ptokax it self checks if IP is correct then theres no need to do so in the lib.. The obove code was only a sample.. THis has not been coded yet, only for 1 command for the speed test :)