/
dev-npgsql
/
npgsql
Обзор
Документация
Войти
/
dev-npgsql
/
npgsql
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
test-logs
test/Npgsql.Benchmarks/ResolveHandler.cs
40 строк
1 KB
Nino Floris
Fix benchmarks (#6489)
12 мар 2026, 05:26
Не верифицирован
12 мар 2026, 05:26
0421d2f
Код
Авторство
О чём код?
using BenchmarkDotNet.Attributes; using Npgsql.Internal; using Npgsql.Internal.Postgres; namespace Npgsql.Benchmarks; [MemoryDiagnoser] public class ResolveHandler { 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(); // Alternatively we must build a data source and get it bootstrapped against a real database. (_, var config) = dataSourceBuilder.PrepareConfiguration(); _serializerOptions = new PgSerializerOptions(PostgresMinimalDatabaseInfo.DefaultTypeCatalog, config.ResolverChain); } [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 }