/
dev-npgsql
/
npgsql
Обзор
Документация
Войти
/
dev-npgsql
/
npgsql
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
v10.0.2
test/Npgsql.Benchmarks/ResolveHandler.cs
42 строки
1 KB
Nino Floris
Move all reloadable state into one reference (#6303)
11 ноя 2025, 23:13
Не верифицирован
11 ноя 2025, 23:13
dcbb5c2
Код
Авторство
О чём код?
using BenchmarkDotNet.Attributes; using Npgsql.Internal; using Npgsql.Internal.Postgres; namespace Npgsql.Benchmarks; [MemoryDiagnoser] public class ResolveHandler { NpgsqlDataSource? _dataSource; PgSerializerOptions _serializerOptions = null!; [Params(0, 1, 2)] public int NumPlugins { get; set; } [GlobalSetup] public void Setup() { var dataSourceBuilder = new NpgsqlDataSourceBuilder(); if (NumPlugins > 0) dataSourceBuilder.UseNodaTime(); if (NumPlugins > 1) dataSourceBuilder.UseNetTopologySuite(); _dataSource = dataSourceBuilder.Build(); _serializerOptions = _dataSource.CurrentReloadableState.SerializerOptions; } [GlobalCleanup] public void Cleanup() => _dataSource?.Dispose(); [Benchmark] public PgTypeInfo? ResolveDefault() => _serializerOptions.GetTypeInfoInternal(null, new Oid(23)); // int4 [Benchmark] public PgTypeInfo? ResolveType() => _serializerOptions.GetTypeInfoInternal(typeof(int), null); [Benchmark] public PgTypeInfo? ResolveBoth() => _serializerOptions.GetTypeInfoInternal(typeof(int), new Oid(23)); // int4 }