Faster random binary number generator
Posted: May 5th, 2007, 11:23 am
I have seen various tutorials for gererating random binary numbers including one on Creativecow.net by Dan Ebberts "random hex grid"
http://www.creativecow.net/articles/ebb ... ndex2.html
The problem is speed if you want any more than a few lines of text. Of course they will all play back at 29.97 fps after the preview has been compiled but during that process they are extremely slow.The Creative cow tutorial ran at 1.0 fps and my system has dual 2.0ghz Opterons with 2Gb ram and the O.S on two Seagate drives in raid 0 with two more of the same for playback.I have read about flipped loops with optimized reverse counting and various tutorials on using a StringBuffer function and using switch instead of if statements.I have come up with the following but it still only runs at 1.5 fps.
The final version even has unnecessary tabs and spaces removed. I still need to make it hold for 5 frames maybe that will speed it up. How can I do that?
Or maybe a different approach by using a varation of this tutorial. http://aefreemart.com/2006/09/13/ae-captions/[/url]
http://www.creativecow.net/articles/ebb ... ndex2.html
The problem is speed if you want any more than a few lines of text. Of course they will all play back at 29.97 fps after the preview has been compiled but during that process they are extremely slow.The Creative cow tutorial ran at 1.0 fps and my system has dual 2.0ghz Opterons with 2Gb ram and the O.S on two Seagate drives in raid 0 with two more of the same for playback.I have read about flipped loops with optimized reverse counting and various tutorials on using a StringBuffer function and using switch instead of if statements.I have come up with the following but it still only runs at 1.5 fps.

Or maybe a different approach by using a varation of this tutorial. http://aefreemart.com/2006/09/13/ae-captions/
Code: Select all
function get_random() {
var rn=Math.floor(random()*2);
return rn;
}
function StringBuffer() {
this.buffer = [];
}
StringBuffer.prototype.append = function append(string) {
this.buffer.push(string);
return this;
}
StringBuffer.prototype.toString = function toString() {
return this.buffer.join("");
}
var j=("\r"),i=1559,buf=new StringBuffer();
do
{
switch (true)
{
case (i%130==0):buf.append(j);break;
default:buf.append(get_random());
}
}
while (--i)
text.sourceText=buf.toString();