Files
FastGateway/benchmark/Benchmark.FastGateway/CheckIpInIp.cs
T
token 4a12a73f54 - 增加基准测试
- 修改迁移记录
- 增加黑名单
- 增加白名单
2024-04-04 04:25:50 +08:00

45 lines
922 B
C#

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using FastGateway.Core;
namespace Benchmark.FastGateway;
[SimpleJob(RuntimeMoniker.Net80)]
[MemoryDiagnoser, MaxColumn]
public class CheckIpInIp
{
// 帮我提供一百个ip ip范围 ip段的案例
private static string Ips;
private static string IpRanges;
private static string IpSegments;
[GlobalSetup]
public void Setup()
{
Ips = $"192.168.2.10";
IpRanges = $"192.168.2.1-192.168.2.100";
IpSegments = $"192.168.2.1/24";
}
[Benchmark]
public void UnsafeCheckIpInIpRange()
{
for (var i = 0; i < 10000; i++)
{
IpHelper.UnsafeCheckIpInIpRange(Ips, IpRanges);
}
}
[Benchmark]
public void CheckIpInIpRange()
{
for (var i = 0; i < 10000; i++)
{
IpHelper.CheckIpInIpRange(Ips, IpRanges);
}
}
}