This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* install BenchmarkDotNet from CI feed. remove Microsoft.NET.Test.Sdk which was generating Program.Main * port simple type to BenchmarkDotNet * don't run Benchmarks as part of test run * port one benchmark with `[Params]` and `[GlobalSetup]` as an example * don't run Benchmarks as part of test run * post code review changes * remove the cast
- Loading branch information
1 parent
b8b23c3
commit d48f2c0
Showing
9 changed files
with
150 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Text; | ||
using System.Text.Utf8; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace Benchmarks.Encodings | ||
{ | ||
public class AsciiDecoding | ||
{ | ||
private byte[] bytes; | ||
|
||
[Params("/plaintext", "text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7")] | ||
public string Text; | ||
|
||
[GlobalSetup] | ||
public void Setup() => bytes = Encoding.ASCII.GetBytes(Text); | ||
|
||
[Benchmark] | ||
public string AsciiToStringPrimitives() => System.Buffers.Text.Encodings.Ascii.ToUtf16String(bytes); | ||
|
||
[Benchmark(Baseline = true)] | ||
public string AsciiToStringClr() => Encoding.ASCII.GetString(bytes); | ||
|
||
[Benchmark] | ||
public string Utf8ToStringTextEncoder() => new Utf8Span(bytes).ToString(); | ||
} | ||
} | ||
|
Oops, something went wrong.