Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Array.getdata Turbo Charged, code optimization
cybernetix
post Oct 26 2004, 05:01 PM
Post #1


ReloadeD
Group Icon
Group: Honored
Posts: 562
Joined: 20-May 04
From: Belgrade, Serbia
Member No.: 17





well, we all know that some actions can be performed
this way or another, faster or slower. but, some actions
must be fast, couse it might be whole movie is awaiting
for it, for example - loading external data. sometime
it is not so important, because 5ms or 20ms will not be
noticeable, but sometime it is very important, because
some function may miss parameters and movie can stuck.

so, I was looking in : gsb's code : for loading data into
array from external text file. nice example for test.


here is the part of original code which should be optimized:

var p=s.split("\n"), q;
for(var i=0,k=-1;iif((q=p[i].trim())!="") {
if(typeOf(fieldSeperator)!="string") this.data[++k]=q;
else {
s=q.split(fieldSeperator.charAt(0));
this.data[++k]=new Array();
for(var j=0;j }
}
}




and here is optimized code:


var p=(s.split(" ").join("")).split("\r\n");
if(fieldSeperator!=undefined) for (i in p)p[i]=p[i].split(fieldSeperator);
this.data.datas=p;



it is not only shortest code, it is faster one. how much faster ?

in my tests, when converts string to 1D array it is faster twice and little
bit more, when converts string to 2D array it is faster 4 to 6 times,
depends on datas. and to avoid missunderstandings, both of codes
produces exactly the same final results.

tested with mm flash player 7, win XP SP2, smax 2004.09.10


so, to remind you, sometime, in some actions time is important
and loading/pushing data is one of the most critical moments.


you can downolad test files from DOWNLOAD SECTION extract files to some
folder than test gsbGetData.swi and cbxGetData.swi . Both of them
will use for test file: datas.txt which contains 100 lines of datas.



note: test must be done in external browser.
 
+Quote Post  Go to the top of the page
cmonney
post Oct 26 2004, 10:00 PM
Post #2


~ Soul Rebel ~
Group Icon
Group: Main Team*
Posts: 3,625
Joined: 18-May 04
From: a mind-altering psychedelic trip
Member No.: 3





THNX A LOT !!! shades.gif
 
+Quote Post  Go to the top of the page
cybernetix
post Dec 13 2004, 09:05 PM
Post #3


ReloadeD
Group Icon
Group: Honored
Posts: 562
Joined: 20-May 04
From: Belgrade, Serbia
Member No.: 17





u r welcome Tip-Hat.gif
 
+Quote Post  Go to the top of the page
RedDragon
post Dec 14 2004, 01:08 AM
Post #4


insert coin
Group Icon
Group: Main Team
Posts: 5,344
Joined: 24-May 04
From: Maastricht
Member No.: 35





missed this topic completely but it sure looks like one to remember for future projects!

thanks!

smile.gif
 
+Quote Post  Go to the top of the page
cmonney
post Jun 9 2005, 09:46 AM
Post #5


~ Soul Rebel ~
Group Icon
Group: Main Team*
Posts: 3,625
Joined: 18-May 04
From: a mind-altering psychedelic trip
Member No.: 3





QUOTE(RedDragon @ Dec 14 2004, 04:08 AM)
missed this topic completely but it sure looks like one to remember for future projects!

thanks!

smile.gif
*


wut 'bouy now???


:whistle:
 
+Quote Post  Go to the top of the page
mosky7
post Jun 23 2005, 05:36 AM
Post #6


New Member
Group Icon
Group: Member
Posts: 10
Joined: 23-June 05
Member No.: 4,945





thank you
 
+Quote Post  Go to the top of the page
omer24
post Nov 18 2005, 10:45 AM
Post #7


Getting Used To The Dots
Group Icon
Group: Member
Posts: 30
Joined: 19-October 05
From: Tel Aviv, Israel
Member No.: 7,656





hmmm learning more & more every day here!
Thanks.
hiya.gif
 
+Quote Post  Go to the top of the page
Faakher
post Dec 28 2005, 04:13 AM
Post #8


Regular Dot
Group Icon
Group: Member
Posts: 57
Joined: 28-December 05
Member No.: 8,750





Thank You Very Much..
For sharing

Faakher
 
+Quote Post  Go to the top of the page
Andrew_F
post Nov 5 2009, 04:40 AM
Post #9


New Member
Group Icon
Group: Member
Posts: 20
Joined: 12-April 09
Member No.: 24,863





uh-h-h-h!! not for my level!! Doh.gif
 
+Quote Post  Go to the top of the page

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 29th July 2010 - 11:03 PM
Package Holidays | Find jobs | Life Insurance | Life Insurance | Home Insurance