|
From: Petr L. <lu...@us...> - 2001-08-24 17:54:08
|
Update of /cvsroot/javaprofiler/library/src/mon
In directory usw-pr-cvs1:/tmp/cvs-serv4667/mon
Added Files:
Makefile Makefile.mak Makefile.rules dir.info monStatData.cpp
monStatData.h monThreadMethod.cpp monThreadMethod.h
monThreadTrace.cpp monThreadTrace.h monTrace.cpp monTrace.h
Log Message:
Monitor profiling
--- NEW FILE: Makefile ---
include ../../config.mk
include Makefile.rules
--- NEW FILE: Makefile.mak ---
!include ../../config.mk
!include Makefile.rules
--- NEW FILE: Makefile.rules ---
monStatData.o \
monStatData.obj: monStatData.cpp ../main/includes.h
$(CCC) $(CPPFLAGS) monStatData.cpp
monTrace.o \
monTrace.obj: monTrace.cpp ../main/includes.h
$(CCC) $(CPPFLAGS) monTrace.cpp
monThreadMethod.o \
monThreadMethod.obj: monThreadMethod.cpp ../main/includes.h
$(CCC) $(CPPFLAGS) monThreadMethod.cpp
monThreadTrace.o \
monThreadTrace.obj: monThreadTrace.cpp ../main/includes.h
$(CCC) $(CPPFLAGS) monThreadTrace.cpp
--- NEW FILE: dir.info ---
FILES = monStatData monThreadMethod monThreadTrace monTrace
CLEAN_FILES = *.pdb *.obj *.o
--- NEW FILE: monStatData.cpp ---
#include "../main/includes.h"
void MonStatData::addMonStat(jlong addHits, jlong addTime) {
hits += addHits;
time += addTime;
setDataChanged();
}
Buffer& MonStatData::dataToBin(Buffer& b) {
b += hits;
b += time;
setDataChanged();
return b;
}
MonStatData& MonStatData::copy(MonStatData& dest, const MonStatData& src) {
dest.hits = src.hits;
dest.time = src.time;
return dest;
}
--- NEW FILE: monStatData.h ---
#ifndef _MON_STAT_DATA_H_
#define _MON_STAT_DATA_H_
/** Statistics data for monitor profiling.
** This class is used as a base class for other classes
** to hold statistics information about time spent
** by waiting on a monitor.
**
** @see Method, MonTrace, Thread, MonThreadMethod, MonThreadTrace
**
** @author Petr Luner */
class MonStatData: public DataBinaryFormat,
public StatDataModification {
public:
/// Total wait time.
jlong time;
/// Number of waits.
jlong hits;
/** Helper flag.
** Indicates whether blocking occures in wait() method.
** It is neccessary to count hits correctly. */
char wait;
public:
/** Constructor.
** Performs statistics initialization. */
MonStatData() {
time = (jlong)0;
hits = (jlong)0;
wait = 0;
};
/** Updates statistics.
**
** @param addHits number of hits to be added
** @param addTime wait time to be added */
virtual void addMonStat(jlong addHits, jlong addTime);
/** Converts statistics data to a binary format used
** for communication with client.
**
** @param b buffer where to append data
**
** @return reference to same Buffer object as argument 'b' */
virtual Buffer& dataToBin(Buffer& b);
public:
/** Copies statistic data. */
static MonStatData& copy( MonStatData& dest, const MonStatData& src);
};
#endif // _MON_STAT_DATA_H_
--- NEW FILE: monThreadMethod.cpp ---
#include "../main/includes.h"
Allocator MonThreadMethod::_allocator( sizeof( MonThreadMethod));
void MonThreadMethod::addMonStat(jlong addHits, jlong addTime) {
MonStatData::addMonStat(addHits, addTime);
method->addMonStat(addHits, addTime);
}
void MonThreadMethod::deactivate() {
prof().activeMonThreadMethods.removeNoRehash(this);
MonThreadTrace* tt = threadTraces.first();
while (tt) {
tt->deactivate();
tt = threadTraces.next(tt);
}
}
--- NEW FILE: monThreadMethod.h ---
#ifndef _MON_THREAD_METHOD_H_
#define _MON_THREAD_METHOD_H_
/** Key for MonThreadMethod class.
** Used for searching in hash tables.
**
** @author Petr Luner */
struct MonThreadMethodKey {
/// thread ID
JNIEnv* envId;
/// method ID
jmethodID methodId;
};
/** Crossroad of threads and methods for monitor profiling.
** This class consists of statistic information about
** method while running in the thread.
** Same method can run in different threads. So it would be useful
** to have an information about each method in each thread.
**
** @author Petr Luner */
class MonThreadMethod: public IdObject,
public LI1,
public LI2,
public LI3,
public MonStatData {
public:
/// parent thread
Thread* thread;
/// parent method
Method* method;
/// associated MonThreadTraces
List<MonThreadTrace,LI2> threadTraces;
public:
/// Default constructor.
MonThreadMethod() :
method( NULL),
thread( NULL)
{};
/** Updates monitor statistics.
** Also updates monitor statistics of corresponding method.
**
** @param addHits number of hits to be added
** @param addTime wait time to be added */
virtual void addMonStat(jlong addHits, jlong addTime);
/** Retrieves object's key.
**
** @param key where to store the key
** @return key
**
** @see Hash */
const MonThreadMethodKey& getKey(MonThreadMethodKey& key) {
thread->getKey(key.envId);
method->getKey(key.methodId);
return key;
}
/** Compares object with given key.
**
** @param key key
** @return 1 (true);
** 0 (false)
**
** @see Hash */
int operator==(const MonThreadMethodKey& key) {
return (*thread == key.envId) && (*method == key.methodId);
}
/** Hash function.
**
** @param reference to a key
** @return hash value */
static int hashKey(const MonThreadMethodKey& key) {
return Thread::hashKey(key.envId) ^ Method::hashKey(key.methodId);
}
/** Performs deactivation. */
void deactivate();
private:
/// allocator
static Allocator _allocator;
public:
/** Overloaded new() operator. */
void* operator new( size_t) { return _allocator.get();}
/** Overloaded delete() operator. */
void operator delete( void* unit) { _allocator.put( unit);}
public:
/** Class identification.
**
** @return unique class type identified */
virtual eClassIdent getClassIdent() { return MON_THREAD_METHOD;}
/** State of object. Once an object is unactive, it remains
** unactive forever.
**
** @return 0 (not active);
** 1 (active) */
virtual int isActive() { return (method->isActive() && thread->isActive());}
/** Indication that object has changed its data.
**
** @return 0 (no change);
** 1 (data changed) */
virtual int isChanged() { return (activeChanged() || dataChanged());} // order dependent !
/** Set the structure is unchanged although it may not be. */
virtual void setUnchanged() {
IdObject::setUnchanged();
clearDataChanged();
}
};
#endif // _MON_THREAD_METHOD_H_
--- NEW FILE: monThreadTrace.cpp ---
#include "../main/includes.h"
Allocator MonThreadTrace::_allocator( sizeof( MonThreadTrace));
void MonThreadTrace::addMonStat(jlong addHits, jlong addTime) {
MonStatData::addMonStat(addHits, addTime);
threadMethod->addMonStat(addHits, addTime);
trace->addMonStat(addHits, addTime);
}
void MonThreadTrace::deactivate() {
prof().activeMonThreadTraces.removeNoRehash(this);
}
--- NEW FILE: monThreadTrace.h ---
#ifndef _MON_THREAD_TRACE_H_
#define _MON_THREAD_TRACE_H_
/** Key for MonThreadTrace class.
** Used for searching in hash tables.
**
** @author Petr Luner */
struct MonThreadTraceKey {
/// thread ID
JNIEnv* envId;
/// trace key
TraceKey traceKey;
};
/** Crossroad of threads and traces for monitor profiling.
** This class consists of statistic information about
** a trace while running in the thread.
** Same trace can run in different threads. So it would be useful
** to have an information about each trace in each thread.
**
** @author Petr Luner */
class MonThreadTrace: public IdObject,
public LI1,
public LI2,
public LI3,
public MonStatData {
public:
/// parent MonThreadMethod
MonThreadMethod* threadMethod;
/// parent MonTrace
MonTrace* trace;
public:
/// Default constructor.
MonThreadTrace() :
threadMethod( NULL),
trace( NULL)
{};
/** Updates monitor statistics.
** Also updates monitor statistics of corresponding MonTrace
** and MonThreadMethod.
**
** @param addHits number of hits to be added
** @param addTime wait time to be added */
virtual void addMonStat(jlong addHits, jlong addTime);
/** Retrieves object's key.
**
** @param key where to store the key
** @return key
**
** @see Hash */
const MonThreadTraceKey& getKey(MonThreadTraceKey& key) {
threadMethod->thread->getKey(key.envId);
trace->getKey(key.traceKey);
return key;
}
/** Compares object with given key.
**
** @param key key
** @return 1 (true);
** 0 (false)
**
** @see Hash */
int operator==(const MonThreadTraceKey& key) {
return (*threadMethod->thread == key.envId) && (*trace == key.traceKey);
}
/** Hash function.
**
** @param reference to a key
** @return hash value */
static int hashKey(const MonThreadTraceKey& key) {
return Thread::hashKey(key.envId) ^ Trace::hashKey(key.traceKey);
}
/** Performs deactivation. */
void deactivate();
private:
/// allocator
static Allocator _allocator;
public:
/** Overloaded new() operator. */
void* operator new( size_t) { return _allocator.get();}
/** Overloaded delete() operator. */
void operator delete( void* unit) { _allocator.put( unit);}
public:
/** Class identification.
**
** @return unique class type identified */
virtual eClassIdent getClassIdent() { return MON_THREAD_TRACE;}
/** State of object. Once an object is unactive, it remains
** unactive forever.
**
** @return 0 (not active);
** 1 (active) */
virtual int isActive() { return (trace->isActive() && threadMethod->isActive());}
/** Indication that object has changed its data.
**
** @return 0 (no change);
** 1 (data changed) */
virtual int isChanged() { return (activeChanged() || dataChanged());} // order dependent !
/** Set the structure is unchanged although it may not be. */
virtual void setUnchanged() {
IdObject::setUnchanged();
clearDataChanged();
}
};
#endif // _MON_THREAD_TRACE_H_
--- NEW FILE: monTrace.cpp ---
#include "../main/includes.h"
Allocator MonTrace::_allocator( sizeof( MonTrace));
void MonTrace::addMonStat(jlong addHits, jlong addTime) {
MonStatData::addMonStat(addHits, addTime);
method->addMonStat(addHits, addTime);
}
void MonTrace::deactivate() {
prof().activeMonTraces.removeNoRehash(this);
}
--- NEW FILE: monTrace.h ---
#ifndef _MON_TRACE_H_
#define _MON_TRACE_H_
/** Trace for monitor profiling.
** We decided to use different traces
** for memory, cpu and monitor profiling, because it should
** be an option to have different granularity of traces
** (their trace frame stack depth) for each type of profiling.
**
** @author Petr Luner */
class MonTrace: public IdObject,
public LI1,
public LI2,
public Trace,
public MonStatData {
public:
/// parent method
Method* method;
/// associated MonThreadTraces
List<MonThreadTrace,LI3> threadTraces;
public:
/// Default constructor.
MonTrace() :
method( NULL)
{};
/** Updates monitor statistics.
** Also updates monitor statistics of corresponding method.
**
** @param addHits number of hits to be added
** @param addTime wait time to be added */
virtual void addMonStat(jlong addHits, jlong addTime);
/** Performs deactivation. */
void deactivate();
private:
/// allocator
static Allocator _allocator;
public:
/** Overloaded new() operator. */
void* operator new( size_t) { return _allocator.get();}
/** Overloaded delete() operator. */
void operator delete( void* unit) { _allocator.put( unit);}
public:
/** Class identification.
**
** @return unique class type identified */
virtual eClassIdent getClassIdent() { return MON_TRACE;}
/** State of object. Once an object is unactive, it remains
** unactive forever.
**
** @return 0 (not active);
** 1 (active) */
virtual int isActive() { return method->isActive();}
/** Indication that object has changed its data.
**
** @return 0 (no change);
** 1 (data changed) */
virtual int isChanged() { return (activeChanged() || dataChanged());} // order dependent !
/** Set the structure is unchanged although it may not be. */
virtual void setUnchanged() {
IdObject::setUnchanged();
clearDataChanged();
}
};
#endif // _MON_TRACE_H_
|