mirror of
https://github.com/gnustep/libs-performance.git
synced 2025-02-24 04:11:19 +00:00
add some diagnostics
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/performance/trunk@31400 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
431f3efb80
commit
0c664e3100
3 changed files with 48 additions and 2 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2010-09-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* performance/GSThreadPool.h:
|
||||||
|
* performance/GSThreadPool.m:
|
||||||
|
Track count of active threads and count of number of methods
|
||||||
|
performed in the thread pool. Display via -description.
|
||||||
|
|
||||||
2010-09-22 Richard Frith-Macdonald <rfm@gnu.org>
|
2010-09-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* GSLinkedList.h:
|
* GSLinkedList.h:
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
BOOL suspended;
|
BOOL suspended;
|
||||||
NSUInteger maxThreads;
|
NSUInteger maxThreads;
|
||||||
NSUInteger threadCount;
|
NSUInteger threadCount;
|
||||||
|
NSUInteger activeCount;
|
||||||
GSThreadLink *idle;
|
GSThreadLink *idle;
|
||||||
GSThreadLink *live;
|
GSThreadLink *live;
|
||||||
NSUInteger maxOperations;
|
NSUInteger maxOperations;
|
||||||
|
@ -50,6 +51,7 @@
|
||||||
GSOperation *lastOperation;
|
GSOperation *lastOperation;
|
||||||
NSUInteger unusedCount;
|
NSUInteger unusedCount;
|
||||||
GSOperation *unused;
|
GSOperation *unused;
|
||||||
|
NSUInteger processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Waits until the pool of operations is empty or until the specified
|
/** Waits until the pool of operations is empty or until the specified
|
||||||
|
@ -91,7 +93,10 @@
|
||||||
* You may add an object more than once, but that may result in the operation
|
* You may add an object more than once, but that may result in the operation
|
||||||
* being performed simultaneously in more than one thread.<br />
|
* being performed simultaneously in more than one thread.<br />
|
||||||
* If the pool is configured with zero threads or zero operations,
|
* If the pool is configured with zero threads or zero operations,
|
||||||
* this method will simply perform the operation immediately.
|
* this method will simply perform the operation immediately.<br />
|
||||||
|
* The operation will be performed in a context where there is an exception
|
||||||
|
* handler set to trap exceptions, and an autorelease pool to deal with
|
||||||
|
* autoreleased objects.
|
||||||
*/
|
*/
|
||||||
- (void) scheduleSelector: (SEL)aSelector
|
- (void) scheduleSelector: (SEL)aSelector
|
||||||
onReceiver: (NSObject*)aReceiver
|
onReceiver: (NSObject*)aReceiver
|
||||||
|
|
|
@ -93,6 +93,19 @@
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString*) description
|
||||||
|
{
|
||||||
|
NSString *result;
|
||||||
|
|
||||||
|
[poolLock lock];
|
||||||
|
result = [NSString stringWithFormat:
|
||||||
|
@"%@ queue: %u(%u) threads: %u(%u) active: %u processed: %u",
|
||||||
|
[super description], operationCount, maxOperations,
|
||||||
|
threadCount, maxThreads, activeCount, processed];
|
||||||
|
[poolLock unlock];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) drain: (NSDate*)before
|
- (BOOL) drain: (NSDate*)before
|
||||||
{
|
{
|
||||||
BOOL result = [self isEmpty];
|
BOOL result = [self isEmpty];
|
||||||
|
@ -220,8 +233,26 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *arp;
|
||||||
|
|
||||||
[poolLock unlock];
|
[poolLock unlock];
|
||||||
[aReceiver performSelector: aSelector withObject: anArgument];
|
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
arp = [NSAutoreleasePool new];
|
||||||
|
[aReceiver performSelector: aSelector withObject: anArgument];
|
||||||
|
[arp release];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
arp = [NSAutoreleasePool new];
|
||||||
|
NSLog(@"[%@-%@] %@",
|
||||||
|
NSStringFromClass([aReceiver class]),
|
||||||
|
NSStringFromSelector(aSelector),
|
||||||
|
localException);
|
||||||
|
[arp release];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,6 +353,7 @@
|
||||||
idle = [link remove];
|
idle = [link remove];
|
||||||
[live insert: link];
|
[live insert: link];
|
||||||
live = link;
|
live = link;
|
||||||
|
activeCount++;
|
||||||
link->op = op;
|
link->op = op;
|
||||||
[link->lock lock];
|
[link->lock lock];
|
||||||
[link->lock unlockWithCondition: 1];
|
[link->lock unlockWithCondition: 1];
|
||||||
|
@ -379,6 +411,7 @@
|
||||||
{
|
{
|
||||||
[link remove];
|
[link remove];
|
||||||
}
|
}
|
||||||
|
activeCount--;
|
||||||
if (threadCount > maxThreads)
|
if (threadCount > maxThreads)
|
||||||
{
|
{
|
||||||
threadCount--;
|
threadCount--;
|
||||||
|
@ -403,6 +436,7 @@
|
||||||
BOOL more = NO;
|
BOOL more = NO;
|
||||||
|
|
||||||
[poolLock lock];
|
[poolLock lock];
|
||||||
|
processed++;
|
||||||
if (unusedCount < maxOperations)
|
if (unusedCount < maxOperations)
|
||||||
{
|
{
|
||||||
if (nil != op->arg)
|
if (nil != op->arg)
|
||||||
|
|
Loading…
Reference in a new issue