From b3c2d40588feb00b6016e001c05d32e1ddbaf76b Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 22 Nov 2025 13:10:24 +0800 Subject: [PATCH] =?UTF-8?q?doc:=20=E5=8E=8B=E5=8A=9B=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- binding/csharp/README.md | 49 +++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/binding/csharp/README.md b/binding/csharp/README.md index 5f1db40..ab3c1b4 100644 --- a/binding/csharp/README.md +++ b/binding/csharp/README.md @@ -24,6 +24,7 @@ ISearcher searcher = new Searcher(CachePolicy , "your xdb file path"); | CachePolicy.Content | Cache the entire `xdb` data. | Yes | | CachePolicy.VectorIndex | Cache `vecotorIndex` to speed up queries and reduce system io pressure by reducing one fixed IO operation. | Yes | | CachePolicy.File | Completely file-based queries | Yes | + ### XDB File Description Generate using [maker](https://github.com/lionsoul2014/ip2region/tree/master/maker/csharp), or [download](https://github.com/lionsoul2014/ip2region/blob/master/data/ip2region.xdb) pre-generated xdb files @@ -47,15 +48,47 @@ provider.GetRequiredKeyedService("IP2Region.Net"); netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0;net9.0;net10.0 ## Performance +// * Summary * -| Method | Mean | Error | StdDev | Median | -|------------ |------------:|----------:|------------:|------------:| -| ContentIPv4 | 101.5 ns | 2.04 ns | 4.57 ns | 103.1 ns | -| VectorIPv4 | 7,488.1 ns | 222.91 ns | 657.26 ns | 7,819.2 ns | -| FileIPv4 | 11,686.9 ns | 59.81 ns | 55.95 ns | 11,707.6 ns | -| ContentIPv6 | 296.1 ns | 1.84 ns | 1.72 ns | 296.2 ns | -| VectorIPv6 | 15,025.1 ns | 938.17 ns | 2,766.21 ns | 16,642.9 ns | -| FileIPv6 | 19,721.0 ns | 807.55 ns | 2,381.08 ns | 20,905.7 ns | +BenchmarkDotNet v0.15.6, Windows 11 (10.0.26200.7171) +13th Gen Intel Core i7-13700 2.10GHz, 1 CPU, 24 logical and 16 physical cores +.NET SDK 10.0.100 + [Host] : .NET 10.0.0 (10.0.0, 10.0.25.52411), X64 RyuJIT x86-64-v3 + DefaultJob : .NET 10.0.0 (10.0.0, 10.0.25.52411), X64 RyuJIT x86-64-v3 + + +| Method | Mean | Error | StdDev | Gen0 | Allocated | +|------------ |-------------:|-----------:|-----------:|-------:|----------:| +| ContentIPv4 | 53.70 ns | 0.296 ns | 0.277 ns | 0.0086 | 136 B | +| VectorIPv4 | 4,446.04 ns | 18.673 ns | 15.593 ns | 0.0076 | 232 B | +| FileIPv4 | 6,712.40 ns | 15.718 ns | 13.934 ns | 0.0153 | 264 B | +| ContentIPv6 | 145.53 ns | 0.331 ns | 0.277 ns | 0.0126 | 200 B | +| VectorIPv6 | 7,058.39 ns | 125.505 ns | 117.398 ns | 0.0381 | 712 B | +| FileIPv6 | 10,657.97 ns | 53.907 ns | 50.425 ns | 0.0458 | 744 B | + +// * Hints * +Outliers + Benchmarks.VectorIPv4: Default -> 2 outliers were removed (4.55 us, 4.58 us) + Benchmarks.FileIPv4: Default -> 1 outlier was removed (6.79 us) + Benchmarks.ContentIPv6: Default -> 2 outliers were removed (148.08 ns, 152.27 ns) + +// * Legends * + Mean : Arithmetic mean of all measurements + Error : Half of 99.9% confidence interval + StdDev : Standard deviation of all measurements + Gen0 : GC Generation 0 collects per 1000 operations + Allocated : Allocated memory per single operation (managed only, inclusive, 1KB = 1024B) + 1 ns : 1 Nanosecond (0.000000001 sec) + +// * Diagnostic Output - MemoryDiagnoser * + + +// ***** BenchmarkRunner: End ***** +Run time: 00:02:06 (126.09 sec), executed benchmarks: 6 + +Global total time: 00:02:13 (133.47 sec), executed benchmarks: 6 +// * Artifacts cleanup * +Artifacts cleanup is finished ## Contributing Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.