text speeds are good

Colin Holgate coiin at rcn.com
Sun Mar 16 14:46:26 EDT 2008


On Mar 16, 2008, at 2:27 PM, Dave Cragg wrote:

> The split was very slow. (I split on a regular expression delimiter,  
> which may have caused the slowness. But it was the equivalent of  
> what Rev does with "for each word") For a 76K file with 13,000 words  
> it took 1900+ms to make the array. Looping though the array takes  
> about 460ms.

I'm not sure what you would have done wrong, but try this test:

filltext();
function filltext() {
	var d1:Date = new Date();
	var ms:int = d1.getTime();
	var t:String = "";
	var w:String;
	for (var i = 0; i<300000; i++) {
		t += "aaaaaaaaaaaaaaaaaaaaaab";
	}
	var tarray:Array = t.split("ab");
	for (i = 0; i<tarray.length; i++) {
		w = tarray[i];
	}
	var d2:Date = new Date();
	var nms:int = d2.getTime();
	trace(nms - ms, t.length);
}

Without the split or the loop through the array, it takes 63 mS, with  
the split it takes 164 mS, with the loop it's 195 mS, and with the  
loop and the transfer of an array entry to a string variable, it's  
still only 206 mS. This is effectively a 6.9MB, 300,000 word test,  
which should be more demanding than your 75k/13,000 word one.

In any case, I was trying to praise Rev's handling of something that  
can be potentially slow, and not trying to find the fastest way that  
it could be done.



More information about the Use-livecode mailing list