Interesting Experiment With String/Sequence Slicing

new topic     » topic index » view thread      » older message » newer message

hi there all,

i  have also just became a registered user of euphoria too
and i must say this is the first time i have found something that
is heaps better than VisualBasic.  i am really interested in how
far one can push euphoria in terms of speed.  one thing
that i noticed was the time it took to slice strings
specially a very large string read from a text file say 5,000 lines,
it seems to be the bottle neck to the global search and replace
function (after originally suspecting it to be the match function
which was quite fine).   i have set up the test below and found
some interesting results :

        1. by allocating the string first then slice appeared to be faster
(anyone can explain?)
        2. measuring string allocation and string slicing on their own
        seems to be really really fast but when combined together
        it appeared very slow.  (which led myself to suspect that
       allocation and slicing only creates references in the intepreter
        and only start executing when the references are actually
        used as variables)

my conclusion from this test is that the either the slicing or the
allocation
method in the interpreter is 'iterative' as opposed to just cutting and
moving
large chunks of string around in the memory, which explains the poor
perfomance?
but there is a good case for iterative because it caters for sequences of
all data
types/structures  rather than just the string type and if this be the case
then
maybe it could provide a cause for us to petition Robert to create
allocation/slicing functions specifically just for the string type sequence
ie utilising the chunk memory cut and move method.  overall my conclusion
could be immoderatly incorrect but i would love hear comments from yous.
thanks

sam lie


----------------------------------------------------------------------
-- standard sequence slicing method

t = time()

for i=1 to 2000 do
 sLine2 = sLine[2..length(sLine)]
end for

t = time() - t
printf(1, "%6.2f seconds\n", t)

----------------------------------------------------------------------
-- faster slicing method by allocating sLine2=sLine  first

t = time()

for i=1 to 2000 do
 sLine2 = sLine
 sLine2 = sLine2[2..length(sLine2)]
end for

t = time() - t
printf(1, "%6.2f seconds\n", t)

----------------------------------------------------------------------
-- time to allocate string (really fast hardly measurable)

t = time()

for i=1 to 2000 do
 sLine2 = sLine
end for

t = time() - t
printf(1, "%6.2f seconds\n", t)

----------------------------------------------------------------------
-- time to slice string without allocating it to another variable (really
fast hardly measurable)

t = time()

for i=1 to 2000 do
 sLine = sLine[2..length(sLine)]
end for

t = time() - t
printf(1, "%6.2f seconds\n", t)




*********************************************************************************
This email and any files transmitted with it may be legally privileged 
and confidential.  If you are not the intended recipient of this email,
you must not disclose or use the information contained in it.  If you 
have received this email in error, please notify us by return email and 
permanently delete the document.
*********************************************************************************

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu