diff --git a/.idea/.idea.ln.collections/.idea/indexLayout.xml b/.idea/.idea.ln.collections/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.ln.collections/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.ln.collections/.idea/vcs.xml b/.idea/.idea.ln.collections/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/.idea.ln.collections/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ln.collections.sln b/ln.collections.sln new file mode 100644 index 0000000..75e8eb4 --- /dev/null +++ b/ln.collections.sln @@ -0,0 +1,48 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.collections", "ln.collections\ln.collections.csproj", "{8033F5A3-945A-4FA0-8A94-FF9A455BEF29}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.collections.test", "ln.collections.test\ln.collections.test.csproj", "{C814B1BC-8EAF-4819-BF70-AAAC08235B5C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8033F5A3-945A-4FA0-8A94-FF9A455BEF29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8033F5A3-945A-4FA0-8A94-FF9A455BEF29}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8033F5A3-945A-4FA0-8A94-FF9A455BEF29}.Debug|x64.ActiveCfg = Debug|Any CPU + {8033F5A3-945A-4FA0-8A94-FF9A455BEF29}.Debug|x64.Build.0 = Debug|Any CPU + {8033F5A3-945A-4FA0-8A94-FF9A455BEF29}.Debug|x86.ActiveCfg = Debug|Any CPU + {8033F5A3-945A-4FA0-8A94-FF9A455BEF29}.Debug|x86.Build.0 = Debug|Any CPU + {8033F5A3-945A-4FA0-8A94-FF9A455BEF29}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8033F5A3-945A-4FA0-8A94-FF9A455BEF29}.Release|Any CPU.Build.0 = Release|Any CPU + {8033F5A3-945A-4FA0-8A94-FF9A455BEF29}.Release|x64.ActiveCfg = Release|Any CPU + {8033F5A3-945A-4FA0-8A94-FF9A455BEF29}.Release|x64.Build.0 = Release|Any CPU + {8033F5A3-945A-4FA0-8A94-FF9A455BEF29}.Release|x86.ActiveCfg = Release|Any CPU + {8033F5A3-945A-4FA0-8A94-FF9A455BEF29}.Release|x86.Build.0 = Release|Any CPU + {C814B1BC-8EAF-4819-BF70-AAAC08235B5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C814B1BC-8EAF-4819-BF70-AAAC08235B5C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C814B1BC-8EAF-4819-BF70-AAAC08235B5C}.Debug|x64.ActiveCfg = Debug|Any CPU + {C814B1BC-8EAF-4819-BF70-AAAC08235B5C}.Debug|x64.Build.0 = Debug|Any CPU + {C814B1BC-8EAF-4819-BF70-AAAC08235B5C}.Debug|x86.ActiveCfg = Debug|Any CPU + {C814B1BC-8EAF-4819-BF70-AAAC08235B5C}.Debug|x86.Build.0 = Debug|Any CPU + {C814B1BC-8EAF-4819-BF70-AAAC08235B5C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C814B1BC-8EAF-4819-BF70-AAAC08235B5C}.Release|Any CPU.Build.0 = Release|Any CPU + {C814B1BC-8EAF-4819-BF70-AAAC08235B5C}.Release|x64.ActiveCfg = Release|Any CPU + {C814B1BC-8EAF-4819-BF70-AAAC08235B5C}.Release|x64.Build.0 = Release|Any CPU + {C814B1BC-8EAF-4819-BF70-AAAC08235B5C}.Release|x86.ActiveCfg = Release|Any CPU + {C814B1BC-8EAF-4819-BF70-AAAC08235B5C}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/ln.collections.test/BTreeTests.cs b/ln.collections.test/BTreeTests.cs new file mode 100644 index 0000000..ec70516 --- /dev/null +++ b/ln.collections.test/BTreeTests.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using NUnit.Framework; + +namespace ln.collections.test +{ + public class BenchmarkBTree + { + + int[] inputs = new int[100000]; + + [SetUp] + public void Setup() + { + Random random = new Random(); + HashSet inputs = new HashSet(); + + while (inputs.Count < this.inputs.Length) + inputs.Add(random.Next()); + this.inputs = inputs.ToArray(); + } + + + [Test] + public void Benchmark() + { + int iters = 10; + + BTree btree = new BTree(); + Meassure(String.Format("BTree({0})", inputs.Length), iters, ()=>{ + foreach (int n in inputs) + btree.Add(n); + + btree.Clear(); + }); + + HashSet hashSet = new HashSet(1000000); + Meassure(String.Format("HashSet({0})", inputs.Length), iters, ()=>{ + foreach (int n in inputs) + hashSet.Add(n); + + hashSet.Clear(); + }); + + Dictionary dict = new Dictionary(); + Meassure(String.Format("Dictionary({0})", inputs.Length), iters, ()=>{ + foreach (int n in inputs) + dict.Add(n, n); + + dict.Clear(); + }); + } + + public void Meassure(string name, int iterations, Action action) + { + TestContext.Error.WriteLine("------ NEASSURE -------------------"); + + while (iterations-->0) + { + DateTime start = DateTime.Now; + action(); + DateTime stop = DateTime.Now; + TestContext.Error.WriteLine("Meassure: {0}: {1}ms", name, (stop - start).TotalMilliseconds); + } + } + + + + } +} \ No newline at end of file diff --git a/ln.collections.test/ln.collections.test.csproj b/ln.collections.test/ln.collections.test.csproj new file mode 100644 index 0000000..c64a042 --- /dev/null +++ b/ln.collections.test/ln.collections.test.csproj @@ -0,0 +1,17 @@ + + + + + false + + net5.0;netcoreapp3.1 + + + + + + + + + +