Alien-Judy

 view release on metacpan or  search on metacpan

src/judy-1.0.5/test/Judy1LTime.c  view on Meta::CPAN

#undef __FUNCTI0N__
#define __FUNCTI0N__ "Random"

_INLINE_ Word_t                 // so INLINING compilers get to look at it.
Random(Word_t newseed)
{
    if (newseed & RandomBit)
    {
        newseed += newseed;
        newseed ^= Magic;
    }
    else
    {
        newseed += newseed;
    }
    newseed &= RandomBit * 2 - 1;
    if (newseed == FirstSeed)
        FAILURE("LFSR failed", newseed);
    return (newseed);
}

_INLINE_ Word_t                 // so INLINING compilers get to look at it.
GetNextIndex(Word_t Index)
{
    if (SkipN)
        Index += SkipN;
    else
        Index = Random(Index);

    return (Index);
}

#undef __FUNCTI0N__
#define __FUNCTI0N__ "main"

int
main(int argc, char *argv[])
{
//  Names of Judy Arrays
    void     *J1 = NULL;        // Judy1
    void     *JL = NULL;        // JudyL

    TIMER_vars(tm1);            // declare timer variables
    Word_t    Count1, CountL;
    Word_t    Bytes;

    double    Mult;
    Pms_t     Pms;
    Word_t    Seed;
    Word_t    PtsPdec = 40;     // points per decade
    Word_t    Groups;           // Number of measurement groups
    Word_t    grp;
    Word_t    Pop1;
    Word_t    Meas;
    int       Col;

    int       c;
    extern char *optarg;

//============================================================
// PARSE INPUT PARAMETERS
//============================================================

    while ((c = getopt(argc, argv, "n:S:T:P:b:B:dDC1LvIla")) != -1)
    {
        switch (c)
        {
        case 'n':              // Max population of arrays
            nElms = strtoul(optarg, NULL, 0); // Size of Linear Array
            if (nElms == 0)
                FAILURE("No tests: -n", nElms);

//          Check if more than a trillion (64 bit only)
            if ((double)nElms > 1e12)
                FAILURE("Too many Indexes=", nElms);
            break;

        case 'S':              // Step Size, 0 == Random
            SkipN = strtoul(optarg, NULL, 0);
            break;

        case 'T':              // Maximum retrieve tests for timing 
            TValues = strtoul(optarg, NULL, 0);
            break;

        case 'P':              // measurement points per decade
            PtsPdec = strtoul(optarg, NULL, 0);
            break;

        case 'b':              // May not work past 35 bits if changed
            StartSeed = strtoul(optarg, NULL, 0);
            break;

        case 'B':              // expanse of data points (random only)
            BValue = strtoul(optarg, NULL, 0);
            if ((BValue > 64)
                ||
                (MagicList[BValue] == 0) || (BValue > (sizeof(Word_t) * 8)))
            {
                ErrorFlag++;
                printf("\nIllegal number of random bits of %lu !!!\n",
                       BValue);
            }
            break;

        case 'v':
            vFlag = 1;         // time Searching
            break;

        case '1':              // time Judy1
            J1Flag = 1;
            break;

        case 'L':              // time JudyL
            JLFlag = 1;
            break;

        case 'd':              // time Judy1Unset JudyLDel
            dFlag = 1;
            break;



( run in 1.431 second using v1.01-cache-2.11-cpan-13bb782fe5a )