Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FastPathTokenizerPlaintextBenchmark.cs « Matching « Microbenchmarks « perf « Routing « Http « src - github.com/dotnet/aspnetcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fd1b881156d3fcd079a61fdf170d6db3a61cb5c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using BenchmarkDotNet.Attributes;

namespace Microsoft.AspNetCore.Routing.Matching;

public class FastPathTokenizerPlaintextBenchmark : FastPathTokenizerBenchmarkBase
{
    private const int MaxCount = 32;
    private static readonly string Input = "/plaintext";

    // This is super hardcoded implementation for comparison, we dont't expect to do better.
    [Benchmark(Baseline = true)]
    public unsafe void Baseline()
    {
        var path = Input;
        var segments = stackalloc PathSegment[MaxCount];

        MinimalBaseline(path, segments, MaxCount);
    }

    [Benchmark]
    public void Implementation()
    {
        var path = Input;
        Span<PathSegment> segments = stackalloc PathSegment[MaxCount];

        FastPathTokenizer.Tokenize(path, segments);
    }
}