mirror of
https://github.com/netfun2000/ip2region.git
synced 2026-02-27 09:44:31 +08:00
feat:support for concurrent file-based queries
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Running;
|
||||
using IP2Region.Net.Abstractions;
|
||||
using IP2Region.Net.XDB;
|
||||
|
||||
BenchmarkRunner.Run(typeof(Program).Assembly);
|
||||
|
||||
public class CachePolicyCompare
|
||||
{
|
||||
private readonly Searcher _contentSearcher = new Searcher(CachePolicy.Content);
|
||||
private readonly Searcher _vectorSearcher = new Searcher(CachePolicy.VectorIndex);
|
||||
private static readonly string XdbPath = Path.Combine(AppContext.BaseDirectory, "IP2Region", "ip2region.xdb");
|
||||
private readonly ISearcher _contentSearcher = new Searcher(CachePolicy.Content, XdbPath);
|
||||
private readonly ISearcher _vectorSearcher = new Searcher(CachePolicy.VectorIndex,XdbPath);
|
||||
private readonly ISearcher _fileSearcher = new Searcher(CachePolicy.File,XdbPath);
|
||||
|
||||
private readonly string _testIpAddress = "114.114.114.114";
|
||||
|
||||
@@ -18,4 +21,9 @@ public class CachePolicyCompare
|
||||
[Benchmark]
|
||||
[BenchmarkCategory(nameof(CachePolicy.VectorIndex))]
|
||||
public void CachePolicy_VectorIndex() => _vectorSearcher.Search(_testIpAddress);
|
||||
|
||||
|
||||
[Benchmark]
|
||||
[BenchmarkCategory(nameof(CachePolicy.File))]
|
||||
public void CachePolicy_File() => _fileSearcher.Search(_testIpAddress);
|
||||
}
|
||||
Reference in New Issue
Block a user