コード例 #1
0
        /// <summary>
        /// Generate a "binary" record suitable for all sort benchmarks *except*
        /// PennySort.
        /// </summary>
        internal static void GenerateRecord(byte[] recBuf, Unsigned16 rand, Unsigned16 recordNumber
                                            )
        {
            /* generate the 10-byte key using the high 10 bytes of the 128-bit
             * random number
             */
            for (int i = 0; i < 10; ++i)
            {
                recBuf[i] = rand.GetByte(i);
            }
            /* add 2 bytes of "break" */
            recBuf[10] = unchecked ((int)(0x00));
            recBuf[11] = unchecked ((int)(0x11));

            /* convert the 128-bit record number to 32 bits of ascii hexadecimal
             * as the next 32 bytes of the record.
             */
            for (int i_1 = 0; i_1 < 32; i_1++)
            {
                recBuf[12 + i_1] = unchecked ((byte)recordNumber.GetHexDigit(i_1));
            }
            /* add 4 bytes of "break" data */
            recBuf[44] = unchecked ((byte)unchecked ((int)(0x88)));
            recBuf[45] = unchecked ((byte)unchecked ((int)(0x99)));
            recBuf[46] = unchecked ((byte)unchecked ((int)(0xAA)));
            recBuf[47] = unchecked ((byte)unchecked ((int)(0xBB)));
            /* add 48 bytes of filler based on low 48 bits of random number */
            for (int i_2 = 0; i_2 < 12; ++i_2)
            {
                recBuf[48 + i_2 * 4] = recBuf[49 + i_2 * 4] = recBuf[50 + i_2 * 4] = recBuf[51 +
                                                                                            i_2 * 4] = unchecked ((byte)rand.GetHexDigit(20 + i_2));
            }
            /* add 4 bytes of "break" data */
            recBuf[96] = unchecked ((byte)unchecked ((int)(0xCC)));
            recBuf[97] = unchecked ((byte)unchecked ((int)(0xDD)));
            recBuf[98] = unchecked ((byte)unchecked ((int)(0xEE)));
            recBuf[99] = unchecked ((byte)unchecked ((int)(0xFF)));
        }
コード例 #2
0
        /// <summary>
        /// Generate an ascii record suitable for all sort benchmarks including
        /// PennySort.
        /// </summary>
        internal static void GenerateAsciiRecord(byte[] recBuf, Unsigned16 rand, Unsigned16
                                                 recordNumber)
        {
            /* generate the 10-byte ascii key using mostly the high 64 bits.
             */
            long temp = rand.GetHigh8();

            if (temp < 0)
            {
                // use biginteger to avoid the negative sign problem
                BigInteger bigTemp = MakeBigInteger(temp);
                recBuf[0] = unchecked ((byte)((byte)(' ') + (bigTemp.Mod(NinetyFive))));
                temp      = bigTemp.Divide(NinetyFive);
            }
            else
            {
                recBuf[0] = unchecked ((byte)((byte)(' ') + (temp % 95)));
                temp     /= 95;
            }
            for (int i = 1; i < 8; ++i)
            {
                recBuf[i] = unchecked ((byte)((byte)(' ') + (temp % 95)));
                temp     /= 95;
            }
            temp = rand.GetLow8();
            if (temp < 0)
            {
                BigInteger bigTemp = MakeBigInteger(temp);
                recBuf[8] = unchecked ((byte)((byte)(' ') + (bigTemp.Mod(NinetyFive))));
                temp      = bigTemp.Divide(NinetyFive);
            }
            else
            {
                recBuf[8] = unchecked ((byte)((byte)(' ') + (temp % 95)));
                temp     /= 95;
            }
            recBuf[9] = unchecked ((byte)((byte)(' ') + (temp % 95)));
            /* add 2 bytes of "break" */
            recBuf[10] = (byte)(' ');
            recBuf[11] = (byte)(' ');

            /* convert the 128-bit record number to 32 bits of ascii hexadecimal
             * as the next 32 bytes of the record.
             */
            for (int i_1 = 0; i_1 < 32; i_1++)
            {
                recBuf[12 + i_1] = unchecked ((byte)recordNumber.GetHexDigit(i_1));
            }
            /* add 2 bytes of "break" data */
            recBuf[44] = (byte)(' ');
            recBuf[45] = (byte)(' ');
            /* add 52 bytes of filler based on low 48 bits of random number */
            for (int i_2 = 0; i_2 < 13; ++i_2)
            {
                recBuf[46 + i_2 * 4] = recBuf[47 + i_2 * 4] = recBuf[48 + i_2 * 4] = recBuf[49 +
                                                                                            i_2 * 4] = unchecked ((byte)rand.GetHexDigit(19 + i_2));
            }
            /* add 2 bytes of "break" data */
            recBuf[98] = (byte)('\r');
            /* nice for Windows */
            recBuf[99] = (byte)('\n');
        }