[go: nahoru, domu]

Skip to content

Commit

Permalink
test:concurrent query ip
Browse files Browse the repository at this point in the history
  • Loading branch information
malus2077 committed Jul 26, 2023
1 parent 7f5ec33 commit df12523
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 683,603 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
<ProjectReference Include="..\IP2Region.Net\IP2Region.Net.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="..\..\..\data\ip2region.xdb">
<Link>IP2Region/ip2region.xdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
13 changes: 7 additions & 6 deletions binding/csharp/IP2Region.Net.Test/IP2Region.Net.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
</ItemGroup>

<ItemGroup>
<Folder Include="TestData" />
</ItemGroup>

<ItemGroup>
<None Update="TestData\ip.merge.txt">
<Content Include="..\..\..\data\ip.merge.txt">
<Link>TestData/ip.merge.txt</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\..\data\ip2region.xdb">
<Link>TestData/ip2region.xdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</Content>
</ItemGroup>

</Project>
13 changes: 9 additions & 4 deletions binding/csharp/IP2Region.Net.Test/SearcherTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace IP2Region.Net.Test;
[TestFixture]
public class SearcherTest
{
private readonly string _xdbPath = Path.Combine(AppContext.BaseDirectory, "TestData", "ip2region.xdb");

public static IEnumerable<string> Ips()
{
yield return "114.114.114.114";
Expand All @@ -15,25 +17,28 @@ public static IEnumerable<string> Ips()
}

[TestCaseSource(nameof(Ips))]
[Parallelizable(ParallelScope.All)]
public void TestSearchCacheContent(string ip)
{
var contentSearcher = new Searcher(CachePolicy.Content);
var contentSearcher = new Searcher(CachePolicy.Content,_xdbPath);
var region = contentSearcher.Search(ip);
Console.WriteLine(region);
}

[TestCaseSource(nameof(Ips))]
[Parallelizable(ParallelScope.All)]
public void TestSearchCacheVector(string ip)
{
var vectorSearcher = new Searcher(CachePolicy.VectorIndex);
var vectorSearcher = new Searcher(CachePolicy.VectorIndex,_xdbPath);
var region = vectorSearcher.Search(ip);
Console.WriteLine(region);
}

[TestCaseSource(nameof(Ips))]
[Parallelizable(ParallelScope.All)]
public void TestSearchCacheFile(string ip)
{
var fileSearcher = new Searcher(CachePolicy.File);
var fileSearcher = new Searcher(CachePolicy.File,_xdbPath);
var region = fileSearcher.Search(ip);
Console.WriteLine(region);
}
Expand All @@ -43,7 +48,7 @@ public void TestSearchCacheFile(string ip)
[TestCase(CachePolicy.File)]
public void TestBenchSearch(CachePolicy cachePolicy)
{
Searcher searcher = new Searcher(cachePolicy);
Searcher searcher = new Searcher(cachePolicy,_xdbPath);
var srcPath = Path.Combine(AppContext.BaseDirectory, "TestData", "ip.merge.txt");

foreach (var line in File.ReadLines(srcPath))
Expand Down
Loading

0 comments on commit df12523

Please sign in to comment.