/
dev-npgsql
/
npgsql
Обзор
Документация
Войти
/
dev-npgsql
/
npgsql
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
v8.0.4
test/Npgsql.Benchmarks/ResolveHandler.cs
42 строки
1 KB
Nino Floris
User resolver PgTypeInfo reuse (#5737)
10 сен 2024, 16:30
Не верифицирован
10 сен 2024, 16:30
f33567b
Код
Авторство
О чём код?
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.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 }