Platforms to show: All Mac Windows Linux Cross-Platform

/DataTypes/Benchmark Dictionary
Function:
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/Benchmark Dictionary
This example is the version from Mon, 5th May 2019.
Project "Benchmark Dictionary.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Const kCreateCount = 10000
Const kFillCount = 10000
Const kQueryCount = 10000
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Function CompareRows(row1 as Integer, row2 as Integer, column as Integer, ByRef result as Integer) As Boolean if column > 0 then dim v1 as Double = val(me.Cell(row1, column)) dim v2 as Double = val(me.Cell(row2, column)) result = v1-v2 Return true end if End EventHandler
End Control
EventHandler Sub Open() BuildKeyArray TestXojoDictionaryIntegerToInteger TestRealDictionaryIntegerToInteger TestPlugDictionaryIntegerToInteger TestXojoDictionaryStringToString TestRealDictionaryStringToString TestPlugDictionaryStringToString true TestPlugDictionaryStringToString false TestXojoDictionaryTextToText TestRealDictionaryTextToText End EventHandler
Sub BuildKeyArray() dim u as integer = kQueryCount * 2 + 2 for i as integer = 0 to u keys.Append str(i) next #if RBVersion >= 2014 then dim keyt() as text = self.keyt for i as integer = 0 to u keyt.Append i.ToText next #endif End Sub
Sub TestPlugDictionaryIntegerToInteger() #Pragma DisableBackgroundTasks dim d as IntegerToIntegerHashMapMBS dim m1 as Double = Microseconds // create for i as integer = 1 to kCreateCount d = new IntegerToIntegerHashMapMBS next dim m2 as Double = Microseconds // fill for i as integer = 1 to kFillCount d.Value(i) = i+1 next dim m3 as Double = Microseconds // fill a full one for i as integer = 1 to kFillCount d.Value(i+1) = i-1 next dim m4 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as integer = d.Value(i) next dim m5 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as integer = d.lookup(i*2, 0) // half will fail next dim m6 as Double = Microseconds List.AddRow "MBS Dictionary Integer to Integer", strm(m2-m1), strm(m3-m2), strm(m4-m3), strm(m5-m4), strm(m6-m5) End Sub
Sub TestPlugDictionaryStringToString(CaseSensitive as Boolean) #Pragma DisableBackgroundTasks dim d as StringToStringHashMapMBS dim m1 as Double = Microseconds // create for i as integer = 1 to kCreateCount d = new StringToStringHashMapMBS(CaseSensitive) next dim m2 as Double = Microseconds // fill for i as integer = 1 to kFillCount d.Value(keys(i)) = keys(i+1) next dim m3 as Double = Microseconds // fill a full one for i as integer = 1 to kFillCount d.Value(keys(i+1)) = keys(i-1) next dim m4 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as string = d.Value(keys(i)) next dim m5 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as string = d.lookup(keys(i*2), "Hello") // half will fail next dim m6 as Double = Microseconds dim postfix as string if CaseSensitive then postfix = " Case Sensitive" end if List.AddRow "MBS Dictionary String to String"+postfix, strm(m2-m1), strm(m3-m2), strm(m4-m3), strm(m5-m4), strm(m6-m5) End Sub
Sub TestRealDictionaryIntegerToInteger() #Pragma DisableBackgroundTasks dim d as Dictionary dim m1 as Double = Microseconds // create for i as integer = 1 to kCreateCount d = new Dictionary next dim m2 as Double = Microseconds // fill for i as integer = 1 to kFillCount d.Value(i) = i+1 next dim m3 as Double = Microseconds // fill a full one for i as integer = 1 to kFillCount d.Value(i+1) = i-1 next dim m4 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as integer = d.Value(i) next dim m5 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as integer = d.lookup(i*2, 0) // half will fail next dim m6 as Double = Microseconds List.AddRow "Old Dictionary Integer to Integer", strm(m2-m1), strm(m3-m2), strm(m4-m3), strm(m5-m4), strm(m6-m5) End Sub
Sub TestRealDictionaryStringToString() #Pragma DisableBackgroundTasks dim d as Dictionary dim m1 as Double = Microseconds // create for i as integer = 1 to kCreateCount d = new Dictionary next dim m2 as Double = Microseconds // fill for i as integer = 1 to kFillCount d.Value(keys(i)) = keys(i+1) next dim m3 as Double = Microseconds // fill a full one for i as integer = 1 to kFillCount d.Value(keys(i+1)) = keys(i-1) next dim m4 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as string = d.Value(keys(i)) next dim m5 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as string = d.lookup(keys(i*2), "Hello") // half will fail next dim m6 as Double = Microseconds List.AddRow "Old Dictionary String to String", strm(m2-m1), strm(m3-m2), strm(m4-m3), strm(m5-m4), strm(m6-m5) End Sub
Sub TestRealDictionaryTextToText() #if RBVersion >= 2014 then dim keyt() as text = self.keyt #Pragma DisableBackgroundTasks dim d as Dictionary dim m1 as Double = Microseconds // create for i as integer = 1 to kCreateCount d = new Dictionary next dim m2 as Double = Microseconds // fill for i as integer = 1 to kFillCount d.Value(keyt(i)) = keyt(i+1) next dim m3 as Double = Microseconds // fill a full one for i as integer = 1 to kFillCount d.Value(keyt(i+1)) = keyt(i-1) next dim m4 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as text = d.Value(keyt(i)) next dim m5 as Double = Microseconds // query dim DefaultText as text = "Hello" for i as integer = 1 to kQueryCount dim n as text = d.lookup(keyt(i*2), defaultText) // half will fail next dim m6 as Double = Microseconds List.AddRow "Old Dictionary Text to Text", strm(m2-m1), strm(m3-m2), strm(m4-m3), strm(m5-m4), strm(m6-m5) #endif End Sub
Sub TestXojoDictionaryIntegerToInteger() #if RBVersion >= 2014 then #Pragma DisableBackgroundTasks dim d as xojo.core.Dictionary dim m1 as Double = Microseconds // create for i as integer = 1 to kCreateCount d = new xojo.core.Dictionary next dim m2 as Double = Microseconds // fill for i as integer = 1 to kFillCount d.Value(i) = i+1 next dim m3 as Double = Microseconds // fill a full one for i as integer = 1 to kFillCount d.Value(i+1) = i-1 next dim m4 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as integer = d.Value(i) next dim m5 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as integer = d.lookup(i*2, 0) // half will fail next dim m6 as Double = Microseconds List.AddRow "New Dictionary Integer to Integer", strm(m2-m1), strm(m3-m2), strm(m4-m3), strm(m5-m4), strm(m6-m5) #endif End Sub
Sub TestXojoDictionaryStringToString() #if RBVersion >= 2014 then #Pragma DisableBackgroundTasks dim d as xojo.Core.Dictionary dim m1 as Double = Microseconds // create for i as integer = 1 to kCreateCount d = new xojo.Core.Dictionary next dim m2 as Double = Microseconds // fill for i as integer = 1 to kFillCount d.Value(keys(i)) = keys(i+1) next dim m3 as Double = Microseconds // fill a full one for i as integer = 1 to kFillCount d.Value(keys(i+1)) = keys(i-1) next dim m4 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as string = d.Value(keys(i)) next dim m5 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as string = d.lookup(keys(i*2), "Hello") // half will fail next dim m6 as Double = Microseconds List.AddRow "New Dictionary String to String", strm(m2-m1), strm(m3-m2), strm(m4-m3), strm(m5-m4), strm(m6-m5) #endif End Sub
Sub TestXojoDictionaryTextToText() #if RBVersion >= 2014 then dim keyt() as text = self.keyt #Pragma DisableBackgroundTasks dim d as xojo.Core.Dictionary dim m1 as Double = Microseconds // create for i as integer = 1 to kCreateCount d = new xojo.Core.Dictionary next dim m2 as Double = Microseconds // fill for i as integer = 1 to kFillCount d.Value(keyt(i)) = keyt(i+1) next dim m3 as Double = Microseconds // fill a full one for i as integer = 1 to kFillCount d.Value(keyt(i+1)) = keyt(i-1) next dim m4 as Double = Microseconds // query for i as integer = 1 to kQueryCount dim n as text = d.Value(keyt(i)) next dim m5 as Double = Microseconds // query dim DefaultText as text = "Hello" for i as integer = 1 to kQueryCount dim n as text = d.lookup(keyt(i*2), DefaultText) // half will fail next dim m6 as Double = Microseconds List.AddRow "New Dictionary Text to Text", strm(m2-m1), strm(m3-m2), strm(m4-m3), strm(m5-m4), strm(m6-m5) #endif End Sub
Function strm(d as Double) As string Return str(d / 1000.0, "0.000")+"ms" End Function
Property Keys() As string
Property keyt As Variant
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS DataTypes Plugin.

The biggest plugin in space...




Links
MBS Xojo Plugins

Start Chat