Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS DataTypes Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /DataTypes/StringMap test
This example is the version from Mon, 5th Apr 2015.
Project "StringMap test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control list Inherits ListBox
ControlInstance list Inherits ListBox
End Control
EventHandler Sub Open()
Dim d as New MessageDialog //declare the MessageDialog object
Dim b as MessageDialogButton //for handling the result
d.icon=MessageDialog.GraphicCaution //display warning icon
d.ActionButton.Caption="Run"
d.CancelButton.Visible= True //show the Cancel button
d.Message="Do you want to start this benchmark?"
d.Explanation="It can take 10 minutes to complete."
b=d.ShowModal //display the dialog
Select Case b //determine which button was pressed.
Case d.ActionButton
//user pressed Save
Case d.CancelButton
//user pressed Cancel
Return
End select
testStringToString
testStringToVariant
testVariantToVariant
testVariantToVariant2
testIntegerToString
testIntegerToVariant
testIntegerToInteger
End EventHandler
Protected Sub testIntegerToInteger()
const max=1000000
#pragma DisableBackgroundTasks
#pragma DisableAutoWaitCursor
dim dic as new Dictionary
dim map as new IntegerToIntegerOrderedMapMBS
dim hashmap as new IntegerToIntegerHashMapMBS
dim i as integer
dim values(max) as Integer
dim keys(max) as integer
dim s as Integer
dim k as integer
dim tmap,tdic,thashmap as integer
me.title="Working on IntegerToInteger"
me.show
list.AddRow ""
list.addrow "values are integer"
list.addrow "keys are integer"
List.AddRow "max="+str(max)
// prepare test data
for i=0 to max
values(i)=i
keys(i)=i
next
values.Shuffle
keys.Shuffle
// fill
tmap=ticks
for i=0 to max
map.value(keys(i))=values(i)
next
tmap=ticks-tmap
thashmap=ticks
for i=0 to max
hashmap.value(keys(i))=values(i)
next
thashmap=ticks-thashmap
tdic=ticks
for i=0 to max
dic.value(keys(i))=values(i)
next
tdic=ticks-tdic
list.addrow "add values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// haskey
tmap=ticks
for i=0 to max
call map.haskey(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.haskey(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.haskey(keys(i))
next
thashmap=ticks-thashmap
list.addrow "using haskey"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// lookup
tmap=ticks
for i=0 to max
call map.lookup(keys(i),-1)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.lookup(keys(i),-1)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.lookup(keys(i),-1)
next
thashmap=ticks-thashmap
list.addrow "using lookup"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// getvalue
tmap=ticks
for i=0 to max
s=map.value(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.value(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.value(keys(i))
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys
tmap=ticks
for i=0 to max
k=map.Key(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
k=hashmap.Key(i)
next
thashmap=ticks-thashmap
list.addrow "get keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys and values
tmap=ticks
for i=0 to max
k=map.Key(i)
s=map.Value(k)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
k=dic.Key(i)
s=dic.Value(k)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
k=hashmap.Key(i)
s=hashmap.Value(k)
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get values at index
tmap=ticks
for i=0 to max
k=map.Key(i)
s=map.ValueAtIndex(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
k=dic.Key(i)
s=dic.Value(k)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
k=hashmap.Key(i)
s=hashmap.ValueAtIndex(i)
next
thashmap=ticks-thashmap
list.addrow "get values at index"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all keys
const maxx=100
dim tempv(-1) as Variant
dim tempi(-1) as integer
tmap=ticks
for i=0 to maxx
tempi=map.Keys
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.Keys
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
tempi=hashmap.Keys
next
thashmap=ticks-thashmap
list.addrow "get all keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all values
tmap=ticks
for i=0 to maxx
tempi=map.values
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.values
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
tempi=hashmap.values
next
thashmap=ticks-thashmap
list.addrow "get all values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
System.DebugLog "hashmap.BinCount: "+str(hashmap.BinCount)
me.title="Finished."
End Sub
Protected Sub testIntegerToString()
const max=1000000
#pragma DisableBackgroundTasks
#pragma DisableAutoWaitCursor
dim dic as new Dictionary
dim map as new IntegerToStringOrderedMapMBS
dim hashmap as new IntegerToStringHashMapMBS
dim i as integer
dim values(max) as string
dim keys(max) as integer
dim s as string
dim k as integer
dim tmap,tdic,thashmap as integer
me.title="Working on IntegerToString"
me.show
list.AddRow ""
list.addrow "values are strings"
list.addrow "keys are integer"
List.AddRow "max="+str(max)
// prepare test data
for i=0 to max
s=str(i)
values(i)=s
keys(i)=i
next
values.Shuffle
keys.Shuffle
// fill
tmap=ticks
for i=0 to max
map.value(keys(i))=values(i)
next
tmap=ticks-tmap
thashmap=ticks
for i=0 to max
hashmap.value(keys(i))=values(i)
next
thashmap=ticks-thashmap
tdic=ticks
for i=0 to max
dic.value(keys(i))=values(i)
next
tdic=ticks-tdic
list.addrow "add values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// haskey
tmap=ticks
for i=0 to max
call map.haskey(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.haskey(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.haskey(keys(i))
next
thashmap=ticks-thashmap
list.addrow "using haskey"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// lookup
tmap=ticks
for i=0 to max
call map.lookup(keys(i),"default")
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.lookup(keys(i),"default")
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.lookup(keys(i),"default")
next
thashmap=ticks-thashmap
list.addrow "using lookup"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// getvalue
tmap=ticks
for i=0 to max
s=map.value(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.value(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.value(keys(i))
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys
tmap=ticks
for i=0 to max
k=map.Key(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
k=hashmap.Key(i)
next
thashmap=ticks-thashmap
list.addrow "get keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys and values
tmap=ticks
for i=0 to max
k=map.Key(i)
s=map.Value(k)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
k=dic.Key(i)
s=dic.Value(k)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
k=hashmap.Key(i)
s=hashmap.Value(k)
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get values at index
tmap=ticks
for i=0 to max
k=map.Key(i)
s=map.ValueAtIndex(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
k=dic.Key(i)
s=dic.Value(k)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
k=hashmap.Key(i)
s=hashmap.ValueAtIndex(i)
next
thashmap=ticks-thashmap
list.addrow "get values at index"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all keys
const maxx=100
dim temp(-1) as string
dim tempv(-1) as Variant
dim tempi(-1) as integer
tmap=ticks
for i=0 to maxx
tempi=map.Keys
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.Keys
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
tempi=hashmap.Keys
next
thashmap=ticks-thashmap
list.addrow "get all keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all values
tmap=ticks
for i=0 to maxx
temp=map.values
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.values
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
temp=hashmap.values
next
thashmap=ticks-thashmap
list.addrow "get all values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
System.DebugLog "hashmap.BinCount: "+str(hashmap.BinCount)
me.title="Finished."
End Sub
Protected Sub testIntegerToVariant()
const max=1000000
#pragma DisableBackgroundTasks
#pragma DisableAutoWaitCursor
dim dic as new Dictionary
dim map as new IntegerToVariantOrderedMapMBS
dim hashmap as new IntegerToVariantHashMapMBS
dim i as integer
dim values(max) as string
dim keys(max) as integer
dim s as string
dim k as integer
dim tmap,tdic,thashmap as integer
me.title="Working on IntegerToVariant"
me.show
list.AddRow ""
list.addrow "values are variant"
list.addrow "keys are integer"
List.AddRow "max="+str(max)
// prepare test data
for i=0 to max
s=str(i)
values(i)=s
keys(i)=i
next
values.Shuffle
keys.Shuffle
// fill
tmap=ticks
for i=0 to max
map.value(keys(i))=values(i)
next
tmap=ticks-tmap
thashmap=ticks
for i=0 to max
hashmap.value(keys(i))=values(i)
next
thashmap=ticks-thashmap
tdic=ticks
for i=0 to max
dic.value(keys(i))=values(i)
next
tdic=ticks-tdic
list.addrow "add values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// haskey
tmap=ticks
for i=0 to max
call map.haskey(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.haskey(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.haskey(keys(i))
next
thashmap=ticks-thashmap
list.addrow "using haskey"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// lookup
tmap=ticks
for i=0 to max
call map.lookup(keys(i),"default")
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.lookup(keys(i),"default")
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.lookup(keys(i),"default")
next
thashmap=ticks-thashmap
list.addrow "using lookup"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// getvalue
tmap=ticks
for i=0 to max
s=map.value(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.value(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.value(keys(i))
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys
tmap=ticks
for i=0 to max
k=map.Key(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
k=hashmap.Key(i)
next
thashmap=ticks-thashmap
list.addrow "get keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys and values
tmap=ticks
for i=0 to max
k=map.Key(i)
s=map.Value(k)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
k=dic.Key(i)
s=dic.Value(k)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
k=hashmap.Key(i)
s=hashmap.Value(k)
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get values at index
tmap=ticks
for i=0 to max
k=map.Key(i)
s=map.ValueAtIndex(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
k=dic.Key(i)
s=dic.Value(k)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
k=hashmap.Key(i)
s=hashmap.ValueAtIndex(i)
next
thashmap=ticks-thashmap
list.addrow "get values at index"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all keys
const maxx=100
dim tempv(-1) as Variant
dim tempi(-1) as integer
tmap=ticks
for i=0 to maxx
tempi=map.Keys
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.Keys
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
tempi=hashmap.Keys
next
thashmap=ticks-thashmap
list.addrow "get all keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all values
tmap=ticks
for i=0 to maxx
tempv=map.values
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.values
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
tempv=hashmap.values
next
thashmap=ticks-thashmap
list.addrow "get all values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
System.DebugLog "hashmap.BinCount: "+str(hashmap.BinCount)
me.title="Finished."
End Sub
Protected Sub testStringToString()
const max=1000000
#pragma DisableBackgroundTasks
#pragma DisableAutoWaitCursor
dim dic as new Dictionary
dim map as new StringToStringOrderedMapMBS
dim hashmap as new StringToStringHashMapMBS
dim i as integer
dim values(max) as string
dim keys(max) as string
dim s as string
dim tmap,tdic,thashmap as integer
me.title="Working on StringToString"
me.show
list.addrow "values are strings"
list.addrow "keys are strings"
List.AddRow "max="+str(max)
// prepare test data
for i=0 to max
s=str(i)
values(i)=s
keys(i)=s
next
values.Shuffle
keys.Shuffle
// fill
tmap=ticks
for i=0 to max
map.value(keys(i))=values(i)
next
tmap=ticks-tmap
thashmap=ticks
for i=0 to max
hashmap.value(keys(i))=values(i)
next
thashmap=ticks-thashmap
tdic=ticks
for i=0 to max
dic.value(keys(i))=values(i)
next
tdic=ticks-tdic
list.addrow "add values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// haskey
tmap=ticks
for i=0 to max
call map.haskey(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.haskey(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.haskey(keys(i))
next
thashmap=ticks-thashmap
list.addrow "using haskey"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// lookup
tmap=ticks
for i=0 to max
call map.lookup(keys(i),"default")
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.lookup(keys(i),"default")
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.lookup(keys(i),"default")
next
thashmap=ticks-thashmap
list.addrow "using lookup"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// getvalue
tmap=ticks
for i=0 to max
s=map.value(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.value(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.value(keys(i))
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys
tmap=ticks
for i=0 to max
s=map.Key(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.Key(i)
next
thashmap=ticks-thashmap
list.addrow "get keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys and values
tmap=ticks
for i=0 to max
s=map.Key(i)
s=map.Value(s)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
s=dic.Value(s)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.Key(i)
s=hashmap.Value(s)
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get values at index
tmap=ticks
for i=0 to max
s=map.Key(i)
s=map.ValueAtIndex(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
s=dic.Value(s)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.Key(i)
s=hashmap.ValueAtIndex(i)
next
thashmap=ticks-thashmap
list.addrow "get values at index"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all keys
const maxx=100
dim temp(-1) as string
dim tempv(-1) as Variant
tmap=ticks
for i=0 to maxx
temp=map.Keys
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.Keys
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
temp=hashmap.Keys
next
thashmap=ticks-thashmap
list.addrow "get all keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all values
tmap=ticks
for i=0 to maxx
temp=map.values
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.values
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
temp=hashmap.values
next
thashmap=ticks-thashmap
list.addrow "get all values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
System.DebugLog "hashmap.BinCount: "+str(hashmap.BinCount)
me.title="Finished."
End Sub
Protected Sub testStringToVariant()
const max=1000000
#pragma DisableBackgroundTasks
#pragma DisableAutoWaitCursor
dim dic as new Dictionary
dim map as new StringToVariantOrderedMapMBS
dim hashmap as new StringToVariantHashMapMBS
dim i as integer
dim values(max) as string
dim keys(max) as string
dim s as string
dim tmap,tdic,thashmap as integer
me.title="Working on StringToVariant"
me.show
list.AddRow ""
list.addrow "values are variants"
list.addrow "keys are strings"
List.AddRow "max="+str(max)
// prepare test data
for i=0 to max
s=str(i)
values(i)=s
keys(i)=s
next
values.Shuffle
keys.Shuffle
// fill
tmap=ticks
for i=0 to max
map.value(keys(i))=values(i)
next
tmap=ticks-tmap
thashmap=ticks
for i=0 to max
hashmap.value(keys(i))=values(i)
next
thashmap=ticks-thashmap
tdic=ticks
for i=0 to max
dic.value(keys(i))=values(i)
next
tdic=ticks-tdic
list.addrow "add values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// getvalue
tmap=ticks
for i=0 to max
s=map.value(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.value(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.value(keys(i))
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// haskey
tmap=ticks
for i=0 to max
call map.haskey(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.haskey(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.haskey(keys(i))
next
thashmap=ticks-thashmap
list.addrow "using haskey"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// lookup
tmap=ticks
for i=0 to max
call map.lookup(keys(i),"default")
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.lookup(keys(i),"default")
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.lookup(keys(i),"default")
next
thashmap=ticks-thashmap
list.addrow "using lookup"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys
tmap=ticks
for i=0 to max
s=map.Key(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.Key(i)
next
thashmap=ticks-thashmap
list.addrow "get keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys and values
tmap=ticks
for i=0 to max
s=map.Key(i)
s=map.Value(s)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
s=dic.Value(s)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.Key(i)
s=hashmap.Value(s)
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get values at index
tmap=ticks
for i=0 to max
s=map.Key(i)
s=map.ValueAtIndex(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
s=dic.Value(s)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.Key(i)
s=hashmap.ValueAtIndex(i)
next
thashmap=ticks-thashmap
list.addrow "get values at index"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all keys
const maxx=100
dim temps(-1) as string
dim tempv(-1) as variant
tmap=ticks
for i=0 to maxx
temps=map.Keys
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.Keys
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
temps=hashmap.Keys
next
thashmap=ticks-thashmap
list.addrow "get all keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all values
tmap=ticks
for i=0 to maxx
tempv=map.values
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.values
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
tempv=hashmap.values
next
thashmap=ticks-thashmap
list.addrow "get all values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
System.DebugLog "hashmap.BinCount: "+str(hashmap.BinCount)
me.title="Finished."
End Sub
Protected Sub testVariantToVariant()
const max=1000000
#pragma DisableBackgroundTasks
#pragma DisableAutoWaitCursor
dim dic as new Dictionary
dim map as new VariantToVariantOrderedMapMBS // very slow because of variant comparison
dim hashmap as new VariantToVariantHashMapMBS
dim i as integer
dim values(max) as string
dim keys(max) as string
dim s as string
dim tmap,tdic,thashmap as integer
me.title="Working on VariantToVariant"
me.show
list.AddRow ""
list.addrow "values are variants"
list.addrow "keys are variants with strings"
List.AddRow "max="+str(max)
// prepare test data
for i=0 to max
s=str(i)
values(i)=s
keys(i)=s
next
values.Shuffle
keys.Shuffle
// fill
tmap=ticks
for i=0 to max
map.value(keys(i))=values(i)
next
tmap=ticks-tmap
thashmap=ticks
for i=0 to max
hashmap.value(keys(i))=values(i)
next
thashmap=ticks-thashmap
tdic=ticks
for i=0 to max
dic.value(keys(i))=values(i)
next
tdic=ticks-tdic
list.addrow "add values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// getvalue
tmap=ticks
for i=0 to max
s=map.value(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.value(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.value(keys(i))
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// haskey
tmap=ticks
for i=0 to max
call map.haskey(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.haskey(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.haskey(keys(i))
next
thashmap=ticks-thashmap
list.addrow "using haskey"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// lookup
tmap=ticks
for i=0 to max
call map.lookup(keys(i),"default")
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.lookup(keys(i),"default")
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.lookup(keys(i),"default")
next
thashmap=ticks-thashmap
list.addrow "using lookup"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys
tmap=ticks
for i=0 to max
s=map.Key(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.Key(i)
next
thashmap=ticks-thashmap
list.addrow "get keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys and values
tmap=ticks
for i=0 to max
s=map.Key(i)
s=map.Value(s)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
s=dic.Value(s)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.Key(i)
s=hashmap.Value(s)
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get values at index
tmap=ticks
for i=0 to max
s=map.Key(i)
s=map.ValueAtIndex(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
s=dic.Value(s)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.Key(i)
s=hashmap.ValueAtIndex(i)
next
thashmap=ticks-thashmap
list.addrow "get values at index"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all keys
const maxx=100
dim tempv(-1) as variant
tmap=ticks
for i=0 to maxx
tempv=map.Keys
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.Keys
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
tempv=hashmap.Keys
next
thashmap=ticks-thashmap
list.addrow "get all keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all values
tmap=ticks
for i=0 to maxx
tempv=map.values
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.values
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
tempv=hashmap.values
next
thashmap=ticks-thashmap
list.addrow "get all values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
System.DebugLog "hashmap.BinCount: "+str(hashmap.BinCount)
me.title="Finished."
End Sub
Protected Sub testVariantToVariant2()
const max=1000000
#pragma DisableBackgroundTasks
#pragma DisableAutoWaitCursor
dim dic as new Dictionary
dim map as new VariantToVariantOrderedMapMBS // very slow because of variant comparison
dim hashmap as new VariantToVariantHashMapMBS
dim i as integer
dim values(max) as string
dim keys(max) as Variant
dim s as Variant
dim tmap,tdic,thashmap as integer
me.title="Working on VariantToVariant with integers"
me.show
list.AddRow ""
list.addrow "values are variants"
list.addrow "keys are variants with integers"
List.AddRow "max="+str(max)
// prepare test data
for i=0 to max
s=str(i)
values(i)=s
keys(i)=i
next
values.Shuffle
keys.Shuffle
// fill
tmap=ticks
for i=0 to max
map.value(keys(i))=values(i)
next
tmap=ticks-tmap
thashmap=ticks
for i=0 to max
hashmap.value(keys(i))=values(i)
next
thashmap=ticks-thashmap
tdic=ticks
for i=0 to max
dic.value(keys(i))=values(i)
next
tdic=ticks-tdic
list.addrow "add values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// getvalue
tmap=ticks
for i=0 to max
s=map.value(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.value(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.value(keys(i))
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// haskey
tmap=ticks
for i=0 to max
call map.haskey(keys(i))
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.haskey(keys(i))
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.haskey(keys(i))
next
thashmap=ticks-thashmap
list.addrow "using haskey"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// lookup
tmap=ticks
for i=0 to max
call map.lookup(keys(i),"default")
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
call dic.lookup(keys(i),"default")
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
call hashmap.lookup(keys(i),"default")
next
thashmap=ticks-thashmap
list.addrow "using lookup"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys
tmap=ticks
for i=0 to max
s=map.Key(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.Key(i)
next
thashmap=ticks-thashmap
list.addrow "get keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get keys and values
tmap=ticks
for i=0 to max
s=map.Key(i)
s=map.Value(s)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
s=dic.Value(s)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.Key(i)
s=hashmap.Value(s)
next
thashmap=ticks-thashmap
list.addrow "get values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get values at index
tmap=ticks
for i=0 to max
s=map.Key(i)
s=map.ValueAtIndex(i)
next
tmap=ticks-tmap
tdic=ticks
for i=0 to max
s=dic.Key(i)
s=dic.Value(s)
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to max
s=hashmap.Key(i)
s=hashmap.ValueAtIndex(i)
next
thashmap=ticks-thashmap
list.addrow "get values at index"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all keys
const maxx=100
dim tempv(-1) as variant
tmap=ticks
for i=0 to maxx
tempv=map.Keys
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.Keys
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
tempv=hashmap.Keys
next
thashmap=ticks-thashmap
list.addrow "get all keys"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
// get all values
tmap=ticks
for i=0 to maxx
tempv=map.values
next
tmap=ticks-tmap
tdic=ticks
for i=0 to maxx
tempv=dic.values
next
tdic=ticks-tdic
thashmap=ticks
for i=0 to maxx
tempv=hashmap.values
next
thashmap=ticks-thashmap
list.addrow "get all values"
list.cell(list.lastIndex,1)=format(tdic/60.0,"0.0")+"s"
list.cell(list.lastIndex,2)=format(tmap/60.0,"0.0")+"s"
list.cell(list.lastIndex,3)=format(thashmap/60.0,"0.0")+"s"
System.DebugLog "hashmap.BinCount: "+str(hashmap.BinCount)
me.title="Finished."
End Sub
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project
The items on this page are in the following plugins: MBS DataTypes Plugin.