NextBytes8() public method

A version of NextBytes that uses a pointer to set 4 bytes of the byte buffer in one operation thus providing a nice speedup. The loop is also partially unrolled to allow out-of-order-execution, this results in about a x3 speedup on an Intel Core i7 920 (Bloomfield). Thus performance may vary wildly on different CPUs depending on the number of execution units available. Another significant speedup is obtained by setting the 4 bytes by indexing pDWord (e.g. pDWord[i++]=_w) instead of dereferencing it (e.g. *pDWord++=_w). Note that this routine requires the unsafe compilation flag to be specified and so is commented out by default.
The byte array length must be divisible by 8.
public NextBytes8 ( byte buffer ) : void
buffer byte
return void
示例#1
0
 public void NextBytes8()
 {
     int sampleCount = 10000000;
     XorShiftRandom rng = new XorShiftRandom();
     byte[] sampleArr = new byte[sampleCount];
     rng.NextBytes8(sampleArr);
     NextByteInner(sampleArr);
 }