redid showConstructDestruct

This commit is contained in:
Marty Kraimer
2010-11-17 15:28:18 -05:00
parent d9a56c68a1
commit 28aad96b34
16 changed files with 112 additions and 234 deletions

View File

@@ -16,42 +16,18 @@ static volatile int64 totalConstruct = 0;
static volatile int64 totalDestruct = 0;
static Mutex *globalMutex = 0;
class CDCallbackPVField : public ConstructDestructCallback {
public:
CDCallbackPVField();
virtual String getConstructName();
virtual int64 getTotalConstruct();
virtual int64 getTotalDestruct();
virtual int64 getTotalReferenceCount();
private:
String name;
};
CDCallbackPVField::CDCallbackPVField()
: name("pvField")
{
getShowConstructDestruct()->registerCallback(this);
}
String CDCallbackPVField::getConstructName() {return name;}
int64 CDCallbackPVField::getTotalConstruct()
static int64 getTotalConstruct()
{
Lock xx(globalMutex);
return totalConstruct;
}
int64 CDCallbackPVField::getTotalDestruct()
static int64 getTotalDestruct()
{
Lock xx(globalMutex);
return totalDestruct;
}
int64 CDCallbackPVField::getTotalReferenceCount()
{
return 0;
}
static ConstructDestructCallback *pConstructDestructCallback;
static void init()
@@ -60,7 +36,9 @@ static void init()
Lock xx(&mutex);
if(globalMutex==0) {
globalMutex = new Mutex();
pConstructDestructCallback = new CDCallbackPVField();
pConstructDestructCallback = new ConstructDestructCallback(
String("pvField"),
getTotalConstruct,getTotalDestruct,0);
}
}

View File

@@ -33,41 +33,19 @@ static volatile int64 totalConstruct = 0;
static volatile int64 totalDestruct = 0;
static Mutex *globalMutex = 0;
class CDCallbackPVIntrospect : public ConstructDestructCallback {
public:
CDCallbackPVIntrospect();
virtual String getConstructName();
virtual int64 getTotalConstruct();
virtual int64 getTotalDestruct();
virtual int64 getTotalReferenceCount();
private:
String name;
};
CDCallbackPVIntrospect::CDCallbackPVIntrospect()
: name("field")
{
getShowConstructDestruct()->registerCallback(this);
}
String CDCallbackPVIntrospect::getConstructName()
{
return name;
}
int64 CDCallbackPVIntrospect::getTotalConstruct()
static int64 getTotalConstruct()
{
Lock xx(globalMutex);
return totalConstruct;
}
int64 CDCallbackPVIntrospect::getTotalDestruct()
static int64 getTotalDestruct()
{
Lock xx(globalMutex);
return totalDestruct;
}
int64 CDCallbackPVIntrospect::getTotalReferenceCount()
static int64 getTotalReferenceCount()
{
return totalReferenceCount;
}
@@ -80,7 +58,9 @@ static void init()
Lock xx(&mutex);
if(globalMutex==0) {
globalMutex = new Mutex();
pConstructDestructCallback = new CDCallbackPVIntrospect();
pConstructDestructCallback = new ConstructDestructCallback(
String("field"),
getTotalConstruct,getTotalDestruct,getTotalReferenceCount);
}
}

View File

@@ -15,37 +15,17 @@ static volatile int64 totalConstruct = 0;
static volatile int64 totalDestruct = 0;
static Mutex *globalMutex = 0;
class CDCallbackPVAuxInfo : public ConstructDestructCallback {
public:
CDCallbackPVAuxInfo();
virtual String getConstructName();
virtual int64 getTotalConstruct();
virtual int64 getTotalDestruct();
virtual int64 getTotalReferenceCount();
private:
String name;
};
CDCallbackPVAuxInfo::CDCallbackPVAuxInfo()
: name("pvAuxInfo")
{
getShowConstructDestruct()->registerCallback(this);
}
String CDCallbackPVAuxInfo::getConstructName() {return name;}
int64 CDCallbackPVAuxInfo::getTotalConstruct()
static int64 getTotalConstruct()
{
Lock xx(globalMutex);
return totalConstruct;
}
int64 CDCallbackPVAuxInfo::getTotalDestruct()
static int64 getTotalDestruct()
{
Lock xx(globalMutex);
return totalDestruct;
}
int64 CDCallbackPVAuxInfo::getTotalReferenceCount()
{
return 0;
}
static ConstructDestructCallback *pConstructDestructCallback;
@@ -55,7 +35,9 @@ static void init()
Lock xx(&mutex);
if(globalMutex==0) {
globalMutex = new Mutex();
pConstructDestructCallback = new CDCallbackPVAuxInfo();
pConstructDestructCallback = new ConstructDestructCallback(
String("pvAuxInfo"),
getTotalConstruct,getTotalDestruct,0);
}
}

View File

@@ -23,11 +23,11 @@ INC += timeFunction.h
LIBSRCS += byteBuffer.cpp
LIBSRCS += bitSet.cpp
LIBSRCS += serializeHelper.cpp
LIBSRCS += showConstructDestruct.cpp
LIBSRCS += linkedListVoid.cpp
LIBSRCS += event.cpp
LIBSRCS += thread.cpp
LIBSRCS += executor.cpp
LIBSRCS += showConstructDestruct.cpp
LIBSRCS += timeStamp.cpp
LIBSRCS += timeFunction.cpp

View File

@@ -22,42 +22,19 @@ static volatile int64 totalDestruct = 0;
static Mutex *globalMutex = 0;
static String alreadyOn("already on list");
class ConstructDestructCallbackEvent : public ConstructDestructCallback {
public:
ConstructDestructCallbackEvent();
virtual String getConstructName();
virtual int64 getTotalConstruct();
virtual int64 getTotalDestruct();
virtual int64 getTotalReferenceCount();
private:
String name;
};
ConstructDestructCallbackEvent::ConstructDestructCallbackEvent()
: name("event")
{
getShowConstructDestruct()->registerCallback(this);
}
String ConstructDestructCallbackEvent::getConstructName() {return name;}
int64 ConstructDestructCallbackEvent::getTotalConstruct()
static int64 getTotalConstruct()
{
Lock xx(globalMutex);
return totalConstruct;
}
int64 ConstructDestructCallbackEvent::getTotalDestruct()
static int64 getTotalDestruct()
{
Lock xx(globalMutex);
return totalDestruct;
}
int64 ConstructDestructCallbackEvent::getTotalReferenceCount()
{
return 0;
}
static ConstructDestructCallback *pConstructDestructCallback;
static void init()
@@ -66,7 +43,9 @@ static void init()
Lock xx(&mutex);
if(globalMutex==0) {
globalMutex = new Mutex();
pConstructDestructCallback = new ConstructDestructCallbackEvent();
pConstructDestructCallback = new ConstructDestructCallback(
String("event"),
getTotalConstruct,getTotalDestruct,0);
}
}

View File

@@ -19,42 +19,17 @@ static volatile int64 totalConstruct = 0;
static volatile int64 totalDestruct = 0;
static Mutex *globalMutex = 0;
class ConstructDestructCallbackExecutor : public ConstructDestructCallback {
public:
ConstructDestructCallbackExecutor();
virtual String getConstructName();
virtual int64 getTotalConstruct();
virtual int64 getTotalDestruct();
virtual int64 getTotalReferenceCount();
private:
String name;
};
ConstructDestructCallbackExecutor::ConstructDestructCallbackExecutor()
: name("executor")
{
getShowConstructDestruct()->registerCallback(this);
}
String ConstructDestructCallbackExecutor::getConstructName() {return name;}
int64 ConstructDestructCallbackExecutor::getTotalConstruct()
static int64 getTotalConstruct()
{
Lock xx(globalMutex);
return totalConstruct;
}
int64 ConstructDestructCallbackExecutor::getTotalDestruct()
static int64 getTotalDestruct()
{
Lock xx(globalMutex);
return totalDestruct;
}
int64 ConstructDestructCallbackExecutor::getTotalReferenceCount()
{
return 0;
}
static ConstructDestructCallback *pConstructDestructCallback;
@@ -63,7 +38,9 @@ static void init() {
Lock xx(&mutex);
if(globalMutex==0) {
globalMutex = new Mutex();
pConstructDestructCallback = new ConstructDestructCallbackExecutor();
pConstructDestructCallback = new ConstructDestructCallback(
String("executor"),
getTotalConstruct,getTotalDestruct,0);
}
}

View File

@@ -19,76 +19,28 @@ static volatile int64 totalListDestruct = 0;
static Mutex *globalMutex = 0;
static String alreadyOnList("already on list");
class CDCallbackLinkedListNode : public ConstructDestructCallback {
public:
CDCallbackLinkedListNode();
virtual String getConstructName();
virtual int64 getTotalConstruct();
virtual int64 getTotalDestruct();
virtual int64 getTotalReferenceCount();
private:
String name;
};
CDCallbackLinkedListNode::CDCallbackLinkedListNode()
: name("linkedListNode")
{
getShowConstructDestruct()->registerCallback(this);
}
String CDCallbackLinkedListNode::getConstructName() {return name;}
int64 CDCallbackLinkedListNode::getTotalConstruct()
static int64 getTotalNodeConstruct()
{
Lock xx(globalMutex);
return totalNodeConstruct;
}
int64 CDCallbackLinkedListNode::getTotalDestruct()
static int64 getTotalNodeDestruct()
{
Lock xx(globalMutex);
return totalNodeDestruct;
}
int64 CDCallbackLinkedListNode::getTotalReferenceCount()
{
return 0;
}
class CDCallbackLinkedList : public ConstructDestructCallback {
public:
CDCallbackLinkedList();
virtual String getConstructName();
virtual int64 getTotalConstruct();
virtual int64 getTotalDestruct();
virtual int64 getTotalReferenceCount();
private:
String name;
};
CDCallbackLinkedList::CDCallbackLinkedList()
: name("linkedList")
{
getShowConstructDestruct()->registerCallback(this);
}
String CDCallbackLinkedList::getConstructName() {return name;}
int64 CDCallbackLinkedList::getTotalConstruct()
static int64 getTotalListConstruct()
{
Lock xx(globalMutex);
return totalNodeConstruct;
return totalListConstruct;
}
int64 CDCallbackLinkedList::getTotalDestruct()
static int64 getTotalListDestruct()
{
Lock xx(globalMutex);
return totalNodeDestruct;
}
int64 CDCallbackLinkedList::getTotalReferenceCount()
{
return 0;
return totalListDestruct;
}
static ConstructDestructCallback *pCDCallbackLinkedListNode;
@@ -100,8 +52,13 @@ static void initPvt()
Lock xx(&mutex);
if(globalMutex==0) {
globalMutex = new Mutex();
pCDCallbackLinkedListNode = new CDCallbackLinkedListNode();
pCDCallbackLinkedList = new CDCallbackLinkedList();
pCDCallbackLinkedListNode = new ConstructDestructCallback(
"linkedListNode",
getTotalNodeConstruct,getTotalNodeDestruct,0);
pCDCallbackLinkedList = new ConstructDestructCallback(
"linkedList",
getTotalListConstruct,getTotalListDestruct,0);
}
}

View File

@@ -19,6 +19,40 @@ typedef LinkedListNode<ConstructDestructCallback> ListNode;
typedef LinkedList<ConstructDestructCallback> List;
static List *list;
ConstructDestructCallback::ConstructDestructCallback(
String name,
getTotal construct,
getTotal destruct,
getTotal reference)
: name(name), construct(construct), destruct(destruct) ,reference(reference)
{
getShowConstructDestruct()->registerCallback(this);
}
ConstructDestructCallback::~ConstructDestructCallback() {}
String ConstructDestructCallback::getConstructName()
{
return name;
}
int64 ConstructDestructCallback::getTotalConstruct()
{
return construct();
}
int64 ConstructDestructCallback:: getTotalDestruct()
{
return destruct();
}
int64 ConstructDestructCallback::getTotalReferenceCount()
{
if(reference==0) return 0;
return reference();
}
ShowConstructDestruct::ShowConstructDestruct() {}
void ShowConstructDestruct::constuctDestructTotals(FILE *fd)

View File

@@ -12,12 +12,25 @@
namespace epics { namespace pvData {
class ConstructDestructCallback {
typedef int64 (*getTotal)();
class ConstructDestructCallback : private NoDefaultMethods {
public:
virtual String getConstructName() = 0;
virtual int64 getTotalConstruct() = 0;
virtual int64 getTotalDestruct() = 0;
virtual int64 getTotalReferenceCount() = 0;
ConstructDestructCallback(
String name,
getTotal construct,
getTotal destruct,
getTotal reference);
String getConstructName();
int64 getTotalConstruct();
int64 getTotalDestruct();
int64 getTotalReferenceCount();
private:
~ConstructDestructCallback();
String name;
getTotal construct;
getTotal destruct;
getTotal reference;
};
class ShowConstructDestruct : private NoDefaultMethods {

View File

@@ -47,42 +47,18 @@ static void addThread(Thread *thread);
static void removeThread(Thread *thread);
static ThreadList *list;
class ConstructDestructCallbackThread : public ConstructDestructCallback {
public:
ConstructDestructCallbackThread();
virtual String getConstructName();
virtual int64 getTotalConstruct();
virtual int64 getTotalDestruct();
virtual int64 getTotalReferenceCount();
private:
String name;
};
ConstructDestructCallbackThread::ConstructDestructCallbackThread()
: name("thread")
{
getShowConstructDestruct()->registerCallback(this);
}
String ConstructDestructCallbackThread::getConstructName() {return name;}
int64 ConstructDestructCallbackThread::getTotalConstruct()
static int64 getTotalConstruct()
{
Lock xx(globalMutex);
return totalConstruct;
}
int64 ConstructDestructCallbackThread::getTotalDestruct()
static int64 getTotalDestruct()
{
Lock xx(globalMutex);
return totalDestruct;
}
int64 ConstructDestructCallbackThread::getTotalReferenceCount()
{
return 0;
}
static ConstructDestructCallback *pConstructDestructCallback;
static void init()
@@ -92,7 +68,9 @@ static void init()
if(globalMutex==0) {
globalMutex = new Mutex();
list = new ThreadList();
pConstructDestructCallback = new ConstructDestructCallbackThread();
pConstructDestructCallback = new ConstructDestructCallback(
String("thread"),
getTotalConstruct,getTotalDestruct,0);
}
}

View File

@@ -18,4 +18,4 @@ stack 4 3 2 1 0
Ordered Queue test
list 0 1 2 3 4
linkedListNode: totalConstruct 4041 totalDestruct 4038
linkedList: totalConstruct 4041 totalDestruct 4038
linkedList: totalConstruct 9 totalDestruct 8

View File

@@ -5,16 +5,16 @@ time per iteration 0.000025 microseconds
time per addTail/removeHead 0.000000 microseconds
Time test locked
diff 174.679436 milliSeconds
time per iteration 174.679436 microseconds
time per addTail/removeHead 0.087340 microseconds
diff 183.634382 milliSeconds
time per iteration 183.634382 microseconds
time per addTail/removeHead 0.091817 microseconds
Time ArrayList test
diff 647.840314 milliSeconds
time per iteration 647.840314 microseconds
time per addTail/removeHead 0.323920 microseconds
diff 647.257745 milliSeconds
time per iteration 647.257745 microseconds
time per addTail/removeHead 0.323629 microseconds
Time ArrayList test locked
diff 803.728035 milliSeconds
time per iteration 803.728035 microseconds
time per addTail/removeHead 0.401864 microseconds
diff 810.656009 milliSeconds
time per iteration 810.656009 microseconds
time per addTail/removeHead 0.405328 microseconds

View File

@@ -18,4 +18,4 @@ stack 4 3 2 1 0
Ordered Queue test
list 0 1 2 3 4
linkedListNode: totalConstruct 4041 totalDestruct 4038
linkedList: totalConstruct 4041 totalDestruct 4038
linkedList: totalConstruct 9 totalDestruct 8

View File

@@ -2,7 +2,7 @@ threads
basic middle
linkedListNode: totalConstruct 17 totalDestruct 10
linkedList: totalConstruct 17 totalDestruct 10
linkedList: totalConstruct 6 totalDestruct 4
event: totalConstruct 8 totalDestruct 8
thread: totalConstruct 2 totalDestruct 2
executor: totalConstruct 2 totalDestruct 2

View File

@@ -1 +1 @@
time per call 34.089829 microseconds
time per call 38.976797 microseconds

View File

@@ -2,7 +2,7 @@ threads
basic middle
linkedListNode: totalConstruct 17 totalDestruct 10
linkedList: totalConstruct 17 totalDestruct 10
linkedList: totalConstruct 6 totalDestruct 4
event: totalConstruct 8 totalDestruct 8
thread: totalConstruct 2 totalDestruct 2
executor: totalConstruct 2 totalDestruct 2