installed
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Author Jeffrey O. Hill
|
||||
* johill@lanl.gov
|
||||
* 505 665 1831
|
||||
*
|
||||
* Experimental Physics and Industrial Control System (EPICS)
|
||||
*
|
||||
* Copyright 1991, the Regents of the University of California,
|
||||
* and the University of Chicago Board of Governors.
|
||||
*
|
||||
* This software was produced under U.S. Government contracts:
|
||||
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
|
||||
* and (W-31-109-ENG-38) at Argonne National Laboratory.
|
||||
*
|
||||
* Initial development by:
|
||||
* The Controls and Automation Group (AT-8)
|
||||
* Ground Test Accelerator
|
||||
* Accelerator Technology Division
|
||||
* Los Alamos National Laboratory
|
||||
*
|
||||
* Co-developed with
|
||||
* The Controls and Computing Group
|
||||
* Accelerator Systems Division
|
||||
* Advanced Photon Source
|
||||
* Argonne National Laboratory
|
||||
*
|
||||
*
|
||||
* History
|
||||
* $Log$
|
||||
*
|
||||
* NOTES:
|
||||
* .01 Storage for identifier must persist until an item is deleted
|
||||
* .02 class T must derive from class ID and tsSLNode<T>
|
||||
*/
|
||||
|
||||
#ifndef INCresourceLibcc
|
||||
#define INCresourceLibcc
|
||||
|
||||
#include <math.h>
|
||||
|
||||
//
|
||||
// resTable<T,ID>::init()
|
||||
//
|
||||
template <class T, class ID>
|
||||
int resTable<T,ID>::init(unsigned nHashTableEntries)
|
||||
{
|
||||
unsigned nbits;
|
||||
|
||||
if (nHashTableEntries<1u) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
//
|
||||
// count the number of bits in the hash index
|
||||
//
|
||||
for (nbits=0; nbits<resTableIndexBitWidth; nbits++) {
|
||||
this->hashIdMask = (1<<nbits) - 1;
|
||||
if ( ((nHashTableEntries-1) & ~this->hashIdMask) == 0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
this->hashIdNBits = nbits;
|
||||
this->nInUse = 0u;
|
||||
this->pTable = new tsSLList<T> [this->hashIdMask+1u];
|
||||
if (!pTable) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// resTable<T,ID>::destroyAllEntries()
|
||||
//
|
||||
template <class T, class ID>
|
||||
void resTable<T,ID>::destroyAllEntries()
|
||||
{
|
||||
tsSLList<T> *pList = this->pTable;
|
||||
|
||||
while (pList<&this->pTable[this->hashIdMask+1]) {
|
||||
tsSLIter<T> iter(*pList);
|
||||
T *pItem;
|
||||
while ( (pItem = iter()) ) {
|
||||
iter.remove();
|
||||
delete pItem;
|
||||
this->nInUse--;
|
||||
}
|
||||
pList++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// resTable<T,ID>::show
|
||||
//
|
||||
template <class T, class ID>
|
||||
void resTable<T,ID>::show (unsigned level)
|
||||
{
|
||||
tsSLList<T> *pList;
|
||||
double X;
|
||||
double XX;
|
||||
double mean;
|
||||
double stdDev;
|
||||
unsigned maxEntries;
|
||||
|
||||
printf("resTable with %d resources installed\n", this->nInUse);
|
||||
|
||||
if (level >=1u) {
|
||||
pList = this->pTable;
|
||||
X = 0.0;
|
||||
XX = 0.0;
|
||||
maxEntries = 0;
|
||||
while (pList < &this->pTable[this->hashIdMask+1]) {
|
||||
unsigned count;
|
||||
tsSLIter<T> iter(*pList);
|
||||
T *pItem;
|
||||
|
||||
count = 0;
|
||||
while ( (pItem = iter()) ) {
|
||||
if (level >= 3u) {
|
||||
pItem->show (level);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
X += count;
|
||||
XX += count*count;
|
||||
if (count>maxEntries) {
|
||||
maxEntries = count;
|
||||
}
|
||||
pList++;
|
||||
}
|
||||
|
||||
mean = X/(this->hashIdMask+1);
|
||||
stdDev = sqrt(XX/(this->hashIdMask+1)- mean*mean);
|
||||
printf(
|
||||
"entries/table index - mean = %f std dev = %f max = %d\n",
|
||||
mean, stdDev, maxEntries);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INCresourceLibcc
|
||||
|
||||
Reference in New Issue
Block a user