Added more IDE files and unit tests
parent
e1eb27ff26
commit
da277bd9c0
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -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
|
|
@ -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<int> inputs = new HashSet<int>();
|
||||
|
||||
while (inputs.Count < this.inputs.Length)
|
||||
inputs.Add(random.Next());
|
||||
this.inputs = inputs.ToArray();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Benchmark()
|
||||
{
|
||||
int iters = 10;
|
||||
|
||||
BTree<int> btree = new BTree<int>();
|
||||
Meassure(String.Format("BTree({0})", inputs.Length), iters, ()=>{
|
||||
foreach (int n in inputs)
|
||||
btree.Add(n);
|
||||
|
||||
btree.Clear();
|
||||
});
|
||||
|
||||
HashSet<int> hashSet = new HashSet<int>(1000000);
|
||||
Meassure(String.Format("HashSet({0})", inputs.Length), iters, ()=>{
|
||||
foreach (int n in inputs)
|
||||
hashSet.Add(n);
|
||||
|
||||
hashSet.Clear();
|
||||
});
|
||||
|
||||
Dictionary<int, int> dict = new Dictionary<int, int>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
|
||||
<TargetFrameworks>net5.0;netcoreapp3.1</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<ProjectReference Include="../ln.collections/ln.collections.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue