Server Talk > Scripting Releases

[SC3] function GetPiece(Str, Reg: string; Number: byte): string;

(1/2) > >>

kicikici:
See attachment:

--- Code: ---gp.pas
--- End code ---

Comparison of executon time to another implementations which can be found on forum:
GetWord: https://forums.soldat.pl/index.php?topic=44988.0
GetPiece2: https://forums.soldat.pl/index.php?topic=44408.0


--- Code: ---(21:31:02) /test getpiece (x.x.x.x)
(21:31:02) 50000 x GetPiece('jedd66f jj92jhfjdh hmmnkjdkjf kjk1ssxjkj1 3lk4l3111 3335', ' ', 3); = 00:00:00,507
(21:31:06) /test getpiece2 (x.x.x.x)
(21:31:13) 50000 x GetPiece2('jedd66f jj92jhfjdh hmmnkjdkjf kjk1ssxjkj1 3lk4l3111 3335', ' ', 3); = 00:00:05,986
(21:31:13) /test getword (x.x.x.x)
(21:31:18) 50000 x GetWord('jedd66f jj92jhfjdh hmmnkjdkjf kjk1ssxjkj1 3lk4l3111 3335', 3); = 00:00:05,030
--- End code ---

soldat-game:
Nice, normal getpiece (sc2) be 0.5 ur be 0.9. (400 ms slowest) but very good

soldat-game:
Wooow im must test it

kicikici:

--- Quote from: Savage on December 11, 2017, 07:16:29 am ---Lil bit faster :P

--- End quote ---

Sure, it will be faster because you have removed code responsible for freeing allocated memory used by temporary TStringList array. It will cause memory leak. Futhermore, you have separated SplitRegExpr function outside of "try except" clause, which can also throw exception. So, it is basically bad approach. To sum up, your modifications are destroyably wrong.

Savage:
U're probably right, thought it's freed automatically like local variable. I had to find some explanation, maybe this one can confirm that http://www.delphibasics.co.uk/Article.asp?Name=Memory

Navigation

[0] Message Index

[#] Next page

Go to full version