Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-26 Thread Mark Winterhalder
index = list.index; len = list.length; while (index length) { It's a problem with len/gth, you overlooked the 'length' in the while() when you renamed it to 'len'. Below is the reworked testing class. It creates the array in the beginning, then

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-26 Thread Cedric Muller
weird results! I do get very different results from the IDE, but I am testing using Flash 8 and Flash Player IDE is 8 could that (it should) explain the difference with results seen in the browser (which has Flash Player 9) ? Cedric index = list.index; len

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-26 Thread Mark Winterhalder
Hey Cedric, What results are you getting? Which one is how much faster in what player? It would surprise me if there were different results for FP8 and FP9, because it runs in the old VM and I doubt they reworked it since it's there for backwards compatibility anyway. It's probably more of a

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-26 Thread Cedric Muller
Hey Cedric, What results are you getting? Which one is how much faster in what player? F8 IDE (FP 8 IDE): flatten: 1576 flatten2: 1554 flatten: 1451 flatten2: 1593 flatten: 1390 flatten2: 1437 flatten: 1526 flatten2: 1439 flatten: 1313 flatten2: 1528 flatten: 1368

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-26 Thread Mark Winterhalder
Thanks, Cedric. I assume those were results compiled by the Flash IDE, so we can conclude recursion *is* the fastest. It's also the most elegant solution, not requirements in this case, but nice to have anyway. I still don't understand why Danny got contrary results, but I like recursion better

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-26 Thread Mark Winterhalder
On 7/26/06, Mark Winterhalder [EMAIL PROTECTED] wrote: I still don't understand why Danny got contrary results, but I like recursion better so let's just leave it like that :) OK, let's not -- I had another look, and found a ! was missing in the recursive method. I've updated the test class

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-26 Thread Mark Winterhalder
OK, my final conclusion: http://www.snafoo.org/tmp/flatten.swf Iterative *is* faster than recursion. Run the test and examine the test class below. (Use an empty .fla, import it, call TestArray.main() ) Also, we learn that whenever you have to get the item at the same position of an array

RE: [Flashcoders] Attention Recursion Speed Experts

2006-07-26 Thread Steven Sacks | BLITZ
Sweet. The only other method that uses recursion is eql. -Steven ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Mark Winterhalder
On 7/25/06, Mark Winterhalder [EMAIL PROTECTED] wrote: On 7/25/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: It is iterating. It still needs to iterate through all nested arrays using the same method, which means recursion. Yes, but function calls aren't the only way to do recursion.

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Mark Winterhalder
On 7/25/06, Mark Winterhalder [EMAIL PROTECTED] wrote: Hmm... now that I'm having coffee and slowly waking up, I'm getting serious doubts about how to do depth-first without function calls. I'm probably wrong, sorry. Interesting problem, though. Got me thinking. So, here's my proposal for a

RE: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Danny Kodicek
On 7/25/06, Mark Winterhalder [EMAIL PROTECTED] wrote: On 7/25/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: It is iterating. It still needs to iterate through all nested arrays using the same method, which means recursion. Yes, but function calls aren't the only way to do

RE: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Danny Kodicek
Ha - you beat me to it... public static function flatten( inArray : Array ) : Array { var outArray : Array = []; var list = inArray; list.index = 0; var item : Object; var index : Number; var length

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Mark Winterhalder
On 7/25/06, Danny Kodicek [EMAIL PROTECTED] wrote: Just out of interest, I tried a speed test using the three methods - mine was the fastest by a very long way: Thanks -- I was hoping somebody would test it :) This seemed a weird result, so I took a look for other differences. It turns out

RE: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Danny Kodicek
BTW, the reason I didn't have a detailed look were the shortened, non-descriptive variable names. This is most likely not necessary. It makes sense for properties, but variables usually are stored as registers (if the compiler chooses to use function2 instead of the old function tag, which

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Mark Winterhalder
On 7/25/06, Mark Winterhalder [EMAIL PROTECTED] wrote: This seems to be extreme. Any chance something is going wrong with the test? Did you wait a few frames before doing the first test to ensure initialization has finished? Maybe switch the order to see if the first one always is the slowest?

RE: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Steven Sacks | BLITZ
First off, thanks to everyone helping on this thread. I originally was using object == typeof(this[a]). Glad to see instanceof Array was fastest. What I'm trying to do here is write new methods for Array (and next up is String) that other languages have but Flash does not. Some of these

RE: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Steven Sacks | BLITZ
Oh, I just noticed that Mark's was fastest. But, I can't get it to work (freezes flash) There seems to be an error in the final while loop. It's a single = not a double ==. Is that a typo? ___ Flashcoders@chattyfig.figleaf.com To change your

RE: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Steven Sacks | BLITZ
Ok, I got Mark's to work however it does not work when turned into a prototype and I set list = this. Why it doesn't work may be the result of another problem, though, and I'm not sure yet what it is, but here's the behavior. I created a movie with 3 buttons. An new array is instantiated.

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Mark Winterhalder
On 7/25/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: Oh, I just noticed that Mark's was fastest. But, I can't get it to work (freezes flash) There seems to be an error in the final while loop. It's a single = not a double ==. Is that a typo? No, not a typo. I know it's confusing, but

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Mark Winterhalder
On 7/25/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: Mark, please check your script to try and find out what's wrong with it. I'd like to run some more accurate comparisons. Ah, yes, just noticed I forgot to look into the freezing problem you mentioned in your last mail (also, I noticed I

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Danny Kodicek
One thing I'm wondering is if a decrementing loop and then a reverse() at the end is faster than an incrementing loop. I'd be astounded if it was! I'm working on compacting Danny's script at the moment. Sounds like an odd idea to me: Mark's was way faster and was essentially the same idea

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Danny Kodicek
Oh, I just noticed that Mark's was fastest. Sorry, replied to an easlier mail before noticing the thread continued... Danny ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive:

RE: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Steven Sacks | BLITZ
Could you post (or send me) the test script, please? Sure, here you go. --- function randomArray(p) { var a = []; for (var i = 0; i p; i++) { if (random(2) random(5)) { a.push(i); } else {

RE: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Bernard Visscher
(;); output: a,b,c,d,e,d,e,d,e,d,e,f,g,h,,i,j Bernard -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Danny Kodicek Verzonden: dinsdag 25 juli 2006 21:51 Aan: Flashcoders mailing list Onderwerp: Re: [Flashcoders] Attention Recursion Speed Experts

RE: [Flashcoders] Attention Recursion Speed Experts

2006-07-25 Thread Mike
] Attention Recursion Speed Experts I don't know if I understand this correctly, but is it making a array flat? Then this is the fastest way I think: var foo : Array = [a, b, c, [d, e,[d, e,[d, e,[d, e, f, [g, [h]], [[], i], j]; var fooString:String = foo.join(;); fooString = fooString.split

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-24 Thread Bernard Poulin
I am assuming this is for AS2 - right? If you want speed that probably means you are dealing with a lot of data(?) 1- What is the typical recursion level? 2- What is the typical number of items? 3- What is the typical size of sub arrays? In general making a function call is not fast at all.

RE: [Flashcoders] Attention Recursion Speed Experts

2006-07-24 Thread Steven Sacks | BLITZ
] Attention Recursion Speed Experts I am assuming this is for AS2 - right? If you want speed that probably means you are dealing with a lot of data(?) 1- What is the typical recursion level? 2- What is the typical number of items? 3- What is the typical size of sub arrays? In general

Re: [Flashcoders] Attention Recursion Speed Experts

2006-07-24 Thread Mark Winterhalder
On 7/25/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote: It is iterating. It still needs to iterate through all nested arrays using the same method, which means recursion. Yes, but function calls aren't the only way to do recursion. What you're doing is essentially like a depth-first