1. Sequence Slicing (Was RE: Tough ciphers?)

Rob, I expect some answers... :)

> ...although I'm beginning to understand the ex.pro file

The three highest times in my ex.pro file are 18.44, 22.68, and 20.06. 
The rest of lines that show up, if at all, are usually (99%) 0.XX.

The three time hogs are sequence slicing calls!!!

Anybody got any tips, tricks, or hints about faster slicing of 
sequences?

They are of the pattern

    x = x[a+1..length(x)]

so, I'm assigning a slice of x back to x. Should I assign it to another 
variable instead? What can I do to make a significant difference, if 
anything?

BTW, the second time hog is actually a find(s1,s2) call, so I just know 
a binary tree or hash list would make things much faster on that one. :)

new topic     » topic index » view message » categorize

2. Re: Sequence Slicing (Was RE: Tough ciphers?)

C.K. Lester writes:
> Anybody got any tips, tricks, or hints about faster slicing of 
> sequences?
>
> They are of the pattern
>
>    x = x[a+1..length(x)]
>
> so, I'm assigning a slice of x back to x. 
> Should I assign it to another variable instead? 

In some cases it will be faster if you assign it to itself.
Given the right conditions (single reference count, fairly large
slice), it will not copy anything. It will simply adjust the 
start and end pointers of the sequence. 

> What can I do to make a significant difference, if anything?

Obviously you are doing this slice statement
many times inside some kind of loop. You'd have to ask
yourself if that's really necessary. I don't think we can
help you without knowing how this fits into your overall
algorithm.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view message » categorize

3. Re: Sequence Slicing (Was RE: Tough ciphers?)

----- Original Message ----- 
From: "C. K. Lester" <cklester at yahoo.com>
> They are of the pattern
> 
>     x = x[a+1..length(x)]

sequence z

integer aout
aout = a + 1

integer lenx
lenx = length(x)

z = repeat(0, lenz - aout)

for i = aout to lenx do
     z[i] = x[i]
end for

x = z

-- or just leave it z instead of the extra copy if you want!

BTW, completly untested to work or for speed but I imagine this might be
faster.......

Euman

new topic     » goto parent     » topic index » view message » categorize

4. Re: Sequence Slicing (Was RE: Tough ciphers?)

> ----- Original Message ----- 
> From: "C. K. Lester" <cklester at yahoo.com>
> > They are of the pattern
> > 
> >     x = x[a+1..length(x)]
> 

Woops, made a mistake in the first one lets try again...

Lets see if this works now.

sequence z
 
 integer aout
aout = a + 1
 
 integer lenx
lenx = length(x) - aout
 
 z = repeat(0, lenx)
 
 for i = 1 to lenx do
      z[i] = x[i]
end for
 
 x = z
 
 -- or just leave it z instead of the extra copy if you want!
 
BTW, completly untested to work or for speed but I imagine this might be
 faster.......
 
 Euman

new topic     » goto parent     » topic index » view message » categorize

5. Re: Sequence Slicing (Was RE: Tough ciphers?)

Last try.....then Im going to bed.

sequence z

integer aout

integer lenx 

integer j

aout = a + 1
lenx = length(x)

z = repeat(0, lenx - aout)

j = 0

for i = aout to lenx do
     j += 1
     z[j] = x[i]
end for

x = z

Euman
euman at bellsouth.net

new topic     » goto parent     » topic index » view message » categorize

6. Re: Sequence Slicing (Was RE: Tough ciphers?)

Chris' results with range_find() are comparable to bechmarks from a while
ago about a binary searcj routine vs. find on a sorted sequence--the break
even point is about 300 for sequence data and about 500 for integer data.

For the specific case of finding the last element of a sequence of 10,000
strings, the benchmark varies quite a bit based on how different the
non-matching strings are from the search string: the fastest times are when
the other strings are a different length, the next fastest when the first
character is different, then when the second character is different, etc.

--Mike Nelson

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu