/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Servers/Kestrel/perf/Microbenchmarks/StringUtilitiesBenchmark.cs
34 строки
1 KB
Pranav K
Use file scoped namespaces (#38076)
06 ноя 2021, 03:52
Не верифицирован
06 ноя 2021, 03:52
a450cb6
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Globalization; using BenchmarkDotNet.Attributes; using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; namespace Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks; public class StringUtilitiesBenchmark { private const int Iterations = 500_000; [Benchmark(Baseline = true, OperationsPerInvoke = Iterations)] public void UintToString() { var connectionId = CorrelationIdGenerator.GetNextId(); for (uint i = 0; i < Iterations; i++) { var id = connectionId + ':' + i.ToString("X8", CultureInfo.InvariantCulture); } } [Benchmark(OperationsPerInvoke = Iterations)] public void ConcatAsHexSuffix() { var connectionId = CorrelationIdGenerator.GetNextId(); for (uint i = 0; i < Iterations; i++) { var id = StringUtilities.ConcatAsHexSuffix(connectionId, ':', i); } } }