On May 31, 2008, at 12:41 PM, Norman Palardy wrote:
> On 31-May-08, at 9:53 AM, Karen wrote:
>
>> Unfortunately users don't have all that info and would have to try
>> and figure it out empirically...
>>
>> Does anyone have feel for these numbers?
>>
> I'd suspect that the number of bytes difference is very small maybe 4
> or 8
I just simulated memory usage for all 4 approaches to implementing
RowTags is a listbox:
1) Put a 2D variant array in the CellTag of row 0
2) Use 2 Dictionaries and put an integer key in the CellTag of row 0
3) Create a class with two tag properties and store an instance of
the CellTag of row 0
4) Use the new Pair class and store an instance of the CellTag of row 0
In all cases I assume that NOTHING is stored in the CellTag of row 0
UNTIL either a RowTag or a cell tag is stored in that row. I
simulated 10,001 rows with tags of ether sort and looked at memory
usage when storing only one type of tag and then both types of tag
values. I used the integer 1 for tag values in all cases.
The results surprised me... using my own class class or the pair
class won unambiguously!
Approach 1 Tag Value 2 Tag Values
My Class 659456 978944
Pair Class 659456 978944
Array 978944 1314816
2 Dictionaries 1540096 2641920
---------------------------
Using my own Class:
Dim Holder(10001) as Variant
Dim MStart, MEnd as double
MStart = Runtime.MemoryUsed
For i as integer = 0 to 10000
Holder(i) = New TagHolder
Next
MEnd = Runtime.MemoryUsed
Dim C as new Clipboard
C.Text = Format(MEnd - Mstart,"0")
Class TagHolder
Sub Constructor()
CellTag = 1
'RowTag = 1
End Sub
Property:RowTag As Variant
Property:CellTag As Variant
End Class
---------------------------
Using Pair Class:
Dim Holder(10001) as Variant
Dim MStart, MEnd as double
MStart = Runtime.MemoryUsed
For i as integer = 0 to 10000
Holder(i) = New Pair(1,NIL)
'Holder(i) = New Pair(1,1)
Next
MEnd = Runtime.MemoryUsed
Dim C as new Clipboard
C.Text = Format(MEnd - Mstart,"0")
---------------------------
Array approach
Dim Holder(10001) as Variant
Dim MStart, MEnd as double
MStart = Runtime.MemoryUsed
For i as integer = 0 to 10000
Holder(i) = VArrMaker
Next
MEnd = Runtime.MemoryUsed
Dim C as new Clipboard
C.Text = Format(MEnd - Mstart,"0")
Function VArrMaker() As Variant
Dim VArr(1) as Variant
VArr(0) = 1
'VArr(1) = 1
Return VArr
End Function
---------------------------
Dictionary approach
Dim Holder(10001) as Variant
Dim MStart, MEnd as double
MStart = Runtime.MemoryUsed
Dim D1 As New Dictionary
Dim D2 As New Dictionary
For i as integer = 0 to 10000
Holder(i) = 1 ' Assigning key value to CellTag
D1.Value(i) = 1
'D2.Value(i) = 1
NExt
MEnd = Runtime.MemoryUsed
Dim C as new Clipboard
C.Text =Format(MEnd- MStart,"0")
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|