Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Improve SocketAddress.ToString() performance#37973

Merged
stephentoub merged 2 commits intodotnet:masterfrom
stephentoub:socketaddresstostring
May 29, 2019
Merged

Improve SocketAddress.ToString() performance#37973
stephentoub merged 2 commits intodotnet:masterfrom
stephentoub:socketaddresstostring

Conversation

@stephentoub
Copy link
Copy Markdown
Member

Following up on request/feedback at #30521 (comment).

Microbenchmark:

using System;
using System.Net;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

[MemoryDiagnoser]
public class Program
{
    static void Main(string[] args) => BenchmarkSwitcher.FromTypes(new[] { typeof(Program) }).Run(args);

    private readonly SocketAddress _addr = new IPEndPoint(IPAddress.Parse("40.112.72.205"), 443).Serialize();

    [Benchmark]
    public string SAToString() => _addr.ToString(); 
}
Method Mean Error StdDev Median Gen 0 Gen 1 Gen 2 Allocated
Before 528.7 ns 10.67 ns 24.73 ns 517.1 ns 0.1183 - - 496 B
After 346.6 ns 4.733 ns 3.695 ns 0.0362 - - - 152 B

Comment thread src/Common/src/System/Net/SocketAddress.cs
@stephentoub stephentoub force-pushed the socketaddresstostring branch from 1c6f8d4 to f9a1efa Compare May 28, 2019 14:19
Comment thread src/Common/src/System/Net/SocketAddress.cs
Comment thread src/Common/src/System/Net/SocketAddress.cs
@stephentoub stephentoub force-pushed the socketaddresstostring branch from f9a1efa to 175dbec Compare May 28, 2019 22:08
@stephentoub stephentoub merged commit 7508b75 into dotnet:master May 29, 2019
@stephentoub stephentoub deleted the socketaddresstostring branch May 29, 2019 00:40
@karelz karelz added this to the 3.0 milestone Jul 16, 2019
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Improve SocketAddress.ToString() performance

* Disable test on Unix


Commit migrated from dotnet/corefx@7508b75
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants