Re: find_all() And More

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...

I'd try something like this:

Here's a benchmarking program for it.

include std/sequence.e 
include std/console.e 
include std/search.e 
 
sequence a = { 0, 1, 2, 3, 0 }, b 
 
b = repeat_pattern( a, 500 ) 
  
function find_all_but( object needle, sequence haystack )  
	integer ix = 1  
	integer jx  
	sequence found = {}  
	while jx with entry do  
		for i = ix to jx - 1 do  
			found &= i  
		end for  
		ix = jx + 1  
	entry  
		jx = find( needle, haystack, ix )  
	end while  
	return found  
end function  
 
atom timer = 3 + time() 
sequence x 
atom c = 0 
 
while time() < timer do 
	c+=1 
	x = find_all_but( 0, a ) 
end while 
?c 
 
sequence g 
timer = 3+time() 
c=0 
g=a=0 -- here's the cheat? 
while time() < timer do 
	c+=1 
	x = find_all( 0, g ) 
end while 
?c 
 
wait_key() 

If I put g=a=0 INSIDE the loop, then your code is waaaaAAAAAyyy faster.

So, huh?

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

Search



Quick Links

User menu

Not signed in.

Misc Menu