File: HeaderUtilitiesBenchmark.cs
Web Access
Project: src\src\Http\Http\perf\Microbenchmarks\Microsoft.AspNetCore.Http.Microbenchmarks.csproj (Microsoft.AspNetCore.Http.Microbenchmarks)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using BenchmarkDotNet.Attributes;
using Microsoft.Extensions.Primitives;
 
namespace Microsoft.Net.Http.Headers;
 
public class HeaderUtilitiesBenchmark
{
    [Benchmark]
    public StringSegment UnescapeAsQuotedString()
    {
        return HeaderUtilities.UnescapeAsQuotedString("\"hello\\\"foo\\\\bar\\\\baz\\\\\"");
    }
 
    [Benchmark]
    public StringSegment EscapeAsQuotedString()
    {
        return HeaderUtilities.EscapeAsQuotedString("\"hello\\\"foo\\\\bar\\\\baz\\\\\"");
    }
}