mirror of
https://github.com/gnustep/libs-performance.git
synced 2025-02-14 15:41:22 +00:00
add GS MemoryReporting extensions for NSObject missing on Mac so that the whole GS base additions are not needed
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/performance/trunk@39190 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
16b09c5202
commit
78dcc717e2
4 changed files with 105 additions and 7 deletions
|
@ -51,6 +51,9 @@
|
|||
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
|
||||
#define class_getInstanceSize(isa) ((struct objc_class *)isa)->instance_size
|
||||
#endif
|
||||
|
||||
#import "NSObject+GSExtensions.h"
|
||||
|
||||
#endif
|
||||
|
||||
@interface GSCache (Threading)
|
||||
|
|
46
NSObject+GSExtensions.h
Normal file
46
NSObject+GSExtensions.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/** Declaration of extension methods for base additions
|
||||
|
||||
Copyright (C) 2003-2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
and: Adam Fedor <fedor@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@interface NSObject(MemoryFootprint)
|
||||
/* This method returns the memory usage of the receiver, excluding any
|
||||
* objects already present in the exclude table.<br />
|
||||
* The argument is a hash table configured to hold non-retained pointer
|
||||
* objects and is used to inform the receiver that its size should not
|
||||
* be counted again if it's already in the table.<br />
|
||||
* The NSObject implementation returns zero if the receiver is in the
|
||||
* table, but otherwise adds itself to the table and returns its memory
|
||||
* footprint (the sum of all of its instance variables, but not any
|
||||
* memory pointed to by those variables).<br />
|
||||
* Subclasses should override this method by calling the superclass
|
||||
* implementation, and either return the result (if it was zero) or
|
||||
* return that value plus the sizes of any memory owned by the receiver
|
||||
* (eg found by calling the same method on objects pointed to by the
|
||||
* receiver's instance variables).
|
||||
*/
|
||||
- (NSUInteger) sizeInBytesExcluding: (NSHashTable*)exclude;
|
||||
@end
|
42
NSObject+GSExtensions.m
Normal file
42
NSObject+GSExtensions.m
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
|
||||
#import <Foundation/NSHashTable.h>
|
||||
|
||||
@implementation NSObject (MemoryFootprint)
|
||||
+ (NSUInteger) sizeInBytesExcluding: (NSHashTable*)exclude
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
- (NSUInteger) sizeInBytesExcluding: (NSHashTable*)exclude
|
||||
{
|
||||
if (0 == NSHashGet(exclude, self))
|
||||
{
|
||||
NSHashInsert(exclude, self);
|
||||
return class_getInstanceSize(object_getClass(self));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@end
|
|
@ -24,6 +24,8 @@
|
|||
85872ECF1284CFC700B4601E /* GSTicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 85872EBE1284CFC700B4601E /* GSTicker.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
85872ED01284CFC700B4601E /* GSTicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 85872EBF1284CFC700B4601E /* GSTicker.m */; };
|
||||
85872ED11284CFC700B4601E /* Performance.h in Headers */ = {isa = PBXBuildFile; fileRef = 85872EC01284CFC700B4601E /* Performance.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
85B7DBDC1C034FBA00AF3090 /* NSObject+GSExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 85B7DBDA1C034FBA00AF3090 /* NSObject+GSExtensions.h */; };
|
||||
85B7DBDD1C034FBA00AF3090 /* NSObject+GSExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 85B7DBDB1C034FBA00AF3090 /* NSObject+GSExtensions.m */; };
|
||||
8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
|
||||
8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
@ -52,6 +54,8 @@
|
|||
85872EC01284CFC700B4601E /* Performance.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Performance.h; sourceTree = "<group>"; };
|
||||
8591FBED1A13422800923420 /* ChangeLog */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ChangeLog; sourceTree = "<group>"; };
|
||||
85B560B3128C6E47003BAF08 /* Performance.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Performance.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
85B7DBDA1C034FBA00AF3090 /* NSObject+GSExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+GSExtensions.h"; sourceTree = "<group>"; };
|
||||
85B7DBDB1C034FBA00AF3090 /* NSObject+GSExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+GSExtensions.m"; sourceTree = "<group>"; };
|
||||
8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
||||
D2F7E79907B2D74100F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
@ -110,6 +114,8 @@
|
|||
08FB77AEFE84172EC02AAC07 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
85B7DBDA1C034FBA00AF3090 /* NSObject+GSExtensions.h */,
|
||||
85B7DBDB1C034FBA00AF3090 /* NSObject+GSExtensions.m */,
|
||||
85872EB01284CFC700B4601E /* GSCache.h */,
|
||||
85872EB11284CFC700B4601E /* GSCache.m */,
|
||||
85872EB21284CFC700B4601E /* GSIndexedSkipList.h */,
|
||||
|
@ -172,6 +178,7 @@
|
|||
85872ECD1284CFC700B4601E /* GSThroughput.h in Headers */,
|
||||
85872ECF1284CFC700B4601E /* GSTicker.h in Headers */,
|
||||
85872ED11284CFC700B4601E /* Performance.h in Headers */,
|
||||
85B7DBDC1C034FBA00AF3090 /* NSObject+GSExtensions.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -207,7 +214,6 @@
|
|||
};
|
||||
buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "Performance" */;
|
||||
compatibilityVersion = "Xcode 2.4";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
English,
|
||||
|
@ -249,6 +255,7 @@
|
|||
85872ECC1284CFC700B4601E /* GSThreadPool.m in Sources */,
|
||||
85872ECE1284CFC700B4601E /* GSThroughput.m in Sources */,
|
||||
85872ED01284CFC700B4601E /* GSTicker.m in Sources */,
|
||||
85B7DBDD1C034FBA00AF3090 /* NSObject+GSExtensions.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -297,8 +304,8 @@
|
|||
1DEB91AF08733DA50010E9CD /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)";
|
||||
ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386";
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
|
||||
ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "x86_64 i386 ppc";
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
FRAMEWORK_VERSION = A;
|
||||
|
@ -321,8 +328,7 @@
|
|||
1DEB91B208733DA50010E9CD /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)";
|
||||
ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386";
|
||||
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
PREBINDING = NO;
|
||||
|
@ -336,8 +342,9 @@
|
|||
1DEB91B308733DA50010E9CD /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)";
|
||||
ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386";
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
|
||||
ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "x86_64 i386 ppc";
|
||||
GCC_MODEL_TUNING = "";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
PREBINDING = NO;
|
||||
|
|
Loading…
Reference in a new issue