Alien-Judy
view release on metacpan or search on metacpan
src/judy-1.0.5/test/Judy1LHTime.c view on Meta::CPAN
if (Words == 0)
printf("OOps JudyFree called with 0 words\n");
free(PWord);
DecWords = Words;
MalFreeCnt++;
// Adjust for overhead of (dl)malloc
if (Words % 1)
DecWords += 1;
else
DecWords += 2;
switch (MalFlag)
{
case JudyMal1:
TotJudy1MemUsed -= DecWords;
break;
case JudyMalL:
TotJudyLMemUsed -= DecWords;
break;
case JudyMalHS:
TotJudyHSMemUsed -= DecWords;
break;
}
} // JudyFree()
// ****************************************************************************
// J U D Y M A L L O C
//
// Higher-level "wrapper" for allocating objects that need not be in RAM,
// although at this time they are in fact only in RAM. Later we hope that some
// entire subtrees (at a JPM or branch) can be "virtual", so their allocations
// and frees should go through this level.
Word_t
JudyMallocVirtual(Word_t Words)
{
return (JudyMalloc(Words));
} // JudyMallocVirtual()
// ****************************************************************************
// J U D Y F R E E
void
JudyFreeVirtual(void *PWord, Word_t Words)
{
JudyFree(PWord, Words);
} // JudyFreeVirtual()
//=======================================================================
// Common macro to handle a failure
#define FAILURE(STR, UL) \
{ \
printf( "\nError: %s %lu, file='%s', 'function='%s', line %d\n", \
STR, (Word_t)(UL), __FILE__, __FUNCTI0N__, __LINE__); \
fprintf(stderr,"\nError: %s %lu, file='%s', 'function='%s', line %d\n", \
STR, (Word_t)(UL), __FILE__, __FUNCTI0N__, __LINE__); \
exit(1); \
}
// Interations without improvement
// Minimum of 2 loops, maximum of 1000000
#define MINLOOPS 2
#define MAXLOOPS 1000000
// Maximum or 10 loops with no improvement
#define ICNT 10
// Structure to keep track of times
typedef struct MEASUREMENTS_STRUCT
{
Word_t ms_delta;
}
ms_t , *Pms_t;
// Specify prototypes for each test routine
int NextNumb(Word_t *PNumber, double *PDNumb, double DMult, Word_t MaxN);
Word_t TestJudyIns(void **J1, void **JL, void **JH, Word_t Seed,
Word_t Elems);
Word_t TestJudyDup(void **J1, void **JL, void **JH, Word_t Seed,
Word_t Elems);
int TestJudyDel(void **J1, void **JL, void **JH, Word_t Seed,
Word_t Elems);
Word_t TestJudyGet(void *J1, void *JL, void *JH, Word_t Seed, Word_t Elems);
int TestJudy1Copy(void *J1, Word_t Elem);
int TestJudyCount(void *J1, void *JL, Word_t LowIndex, Word_t Elems);
Word_t TestJudyNext(void *J1, void *JL, Word_t LowIndex, Word_t Elems);
int TestJudyPrev(void *J1, void *JL, Word_t HighIndex, Word_t Elems);
Word_t TestJudyNextEmpty(void *J1, void *JL, Word_t LowIndex, Word_t Elems);
Word_t TestJudyPrevEmpty(void *J1, void *JL, Word_t HighIndex, Word_t Elems);
//=======================================================================
// These are LFSF feedback taps for bitwidths of 10..64 sized numbers.
// Tested with Seed=0xc1fc to 35 billion numbers
//=======================================================================
Word_t StartSeed = 0xc1fc; // default beginning number
Word_t FirstSeed;
Word_t MagicList[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0..9
0x27f, // 10
0x27f, // 11
0x27f, // 12
0x27f, // 13
0x27f, // 14
( run in 0.504 second using v1.01-cache-2.11-cpan-39bf76dae61 )