jeudi 16 mars 2017

Actionscript 3 , generating random numbers and placing in byte array, faster?

I am trying to generate large byte arrays of random bytes. Using the below code I can generate 10 million random bytes and place in a byte array in about 4 seconds. 2 seconds for the generation and 2 second to place on the array.

for (var i:Number = 0; i < reqLength; i++){
    rnd = Math.random() * 255;
    randomBytes.writeByte(rnd);
}

Does a faster way exist?

I am generating ints because I am creating a byte array of extended asci chars.

Aucun commentaire:

Enregistrer un commentaire