Sign in to follow this  
Followers 0
JackDinn

most efficient (StringSplit StringRegExp _StringExplode) ?

3 posts in this topic

i was just wondering if just comparing the time taken by each command would give me an accurate indication as to which is the most "efficient" way of populating an array from a delimited string ? as it's not just time it's also uPro & ram usage.

#include <Array.au3>
#Include <string.au3>

$string="test|one|two|three|four|five|six|seven|testx testy | mary had a little lamb|"

$A_SS=StringSplit ($string,"|",2)
_ArrayDisplay($A_SS)

$A_SRE=StringRegExp ($string,"\|?(.*?)\|" ,3)
_ArrayDisplay($A_SRE)

$A_SE=_StringExplode ($string,"|")
_ArrayDisplay($A_SE)

If it's just a case of time then i can measure that no prob, obviously it dont really matter with small strings but it might when it comes to reading large files into strings.

what you reckon?


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites



Obviously, StringSplit is perfectly designed for a text delimited by a fixed or not expression character sequence like comma or pipe or maybe 123 in <aaa>123<bbb>123<ccc> etc.. and it's faster than anything else AutoIt has to offer but when it comes to a string split of a text delimited by an expression StringRegExpReplace and StringRegExp will be best, maybe in combination with StringSplit. For example this won't work:

Dim $sStr = '<aaa>123<bbb>123<ccc>123<ddd>'
Dim $aMatch = StringSplit($sStr, '\d+')
;...oÝ÷ Ø­iÊ&n)Ú¶*'¡ô­®)àEèÆ^¦Vy©ÝJÚâ©+jzkyú+·­µêí©Ò¶¸§ bÊ&yƬzÆ®¶­sdFÒb33c·57G"Òb33²fÇC¶fwC³#2fÇC¶&&"fwC³#2fÇC¶662fwC³#2fÇC¶FFBfwC²b33°¤FÒb33c¶ÖF6Ò7G&æu7ÆB7G&æu&VtW&WÆ6Rb33c·57G"Âb33²b3#¶B²b33²Âb33·Âb33²Âb33·Âb33²

... yeah I know, stupid idea anyway. ;]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

... yeah I know, stupid idea anyway. ;]

but its interesting just as a concept :)

also i cant really see why _StringExplode () was introduced as it dont have anything that i can c over StringSplit (), maybe it might save you a line of code if you wanted to use the $Limit var but is that worth a UDF.

anyhow thx.

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0