This repository has been archived by the owner on Aug 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from dscpinheiro/benchmark-dotnet
Added sample project for BenchmarkDotNet
- Loading branch information
Showing
8 changed files
with
82 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.12.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Messages.Helpers\Messages.Helpers.csproj" /> | ||
</ItemGroup> | ||
</Project> |
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,45 @@ | ||
using Messages.Helpers; | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Running; | ||
|
||
namespace Messages.Benchmark | ||
{ | ||
#pragma warning disable CA1822 // Mark members as static | ||
[MinColumn, MaxColumn] | ||
[MarkdownExporter, AsciiDocExporter, HtmlExporter, CsvExporter] | ||
public class MyBenchmark | ||
{ | ||
[Benchmark] | ||
public void ShortPalindromeWord() => "racecar".IsPalindrome(); | ||
|
||
[Benchmark] | ||
public void ShortPalindromeName() => "Anna".IsPalindrome(); | ||
|
||
[Benchmark] | ||
public void SingleCharacter() => "x".IsPalindrome(); | ||
|
||
[Benchmark] | ||
public void SequenceOfRepeatedNumbers() => "9999999999999999999".IsPalindrome(); | ||
|
||
[Benchmark] | ||
public void SequenceOfRandomNumbers() => "865357943037344".IsPalindrome(); | ||
|
||
[Benchmark] | ||
public void EnglishPalindromeMessage() => "Cigar? Toss it in a can. It is so tragic.".IsPalindrome(); | ||
|
||
[Benchmark] | ||
public void NonEnglishPalindromeMessage() => "Socorram-me, subi no ônibus em Marrocos".IsPalindrome(); | ||
|
||
[Benchmark] | ||
public void NonPalindromeMessage() => "this is not a palindrome".IsPalindrome(); | ||
} | ||
#pragma warning restore CA1822 // Mark members as static | ||
|
||
class Program | ||
{ | ||
static void Main() | ||
{ | ||
BenchmarkRunner.Run<MyBenchmark>(); | ||
} | ||
} | ||
} |
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,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
</Project> |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using Messages.Api.Helpers; | ||
using Messages.Helpers; | ||
using System; | ||
using Xunit; | ||
|
||
|