<commit_before>"
SUnit tests for the size of objects in memory
"
Class {
	#name : #SizeInMemoryTest,
	#superclass : #TestCase,
	#category : #'Kernel-Tests-Objects'
}

{ #category : #utils }
SizeInMemoryTest >> align64Bits: size [
	size % 8 = 0
		ifTrue: [ ^ size ]
		ifFalse:[ ^ size + 8 - (size % 8) ].
]

{ #category : #utils }
SizeInMemoryTest >> headerSize [
	" The header is 64 bits"
	^ 8
]

{ #category : #utils }
SizeInMemoryTest >> paddedByteStringSize: numberOfChars [ 
	"64 bits for the header"
	| originalSize  |
	originalSize := self headerSize + (numberOfChars = 0 ifTrue:[1] ifFalse:[numberOfChars]).
		
	^ self align64Bits: originalSize.
]

{ #category : #tests }
SizeInMemoryTest >> testSizeInMemoryCompactClasses [
	self skip.
	"One word for the header + one word per instance variable"
	self assert:  (Association key: 'aKey' value: 23) sizeInMemory = 12.

	"One word for the header + one word per instance variable"
	self assert:  Rectangle new sizeInMemory = 12.


]

{ #category : #tests }
SizeInMemoryTest >> testSizeInMemoryLargeInstances [<commit_msg>21265 SizeInMemoryTest should use utilities category<commit_after>"
SUnit tests for the size of objects in memory
"
Class {
	#name : #SizeInMemoryTest,
	#superclass : #TestCase,
	#category : #'Kernel-Tests-Objects'
}

{ #category : #utilities }
SizeInMemoryTest >> align64Bits: size [
	size % 8 = 0
		ifTrue: [ ^ size ]
		ifFalse:[ ^ size + 8 - (size % 8) ].
]

{ #category : #utilities }
SizeInMemoryTest >> headerSize [
	" The header is 64 bits"
	^ 8
]

{ #category : #utilities }
SizeInMemoryTest >> paddedByteStringSize: numberOfChars [ 
	"64 bits for the header"
	| originalSize  |
	originalSize := self headerSize + (numberOfChars = 0 ifTrue:[1] ifFalse:[numberOfChars]).
		
	^ self align64Bits: originalSize.
]

{ #category : #tests }
SizeInMemoryTest >> testSizeInMemoryCompactClasses [
	self skip.
	"One word for the header + one word per instance variable"
	self assert:  (Association key: 'aKey' value: 23) sizeInMemory = 12.

	"One word for the header + one word per instance variable"
	self assert:  Rectangle new sizeInMemory = 12.


]

{ #category : #tests }
SizeInMemoryTest >> testSizeInMemoryLargeInstances [
{'fraction_non_alphanumeric': 0.11449341208541572, 'fraction_numerical': 0.021353930031803726, 'mean_word_length': 4.242857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2223516', 'n_tokens_mistral': 785, 'n_tokens_neox': 717, 'n_words': 221}