Skip to content

Commit

Permalink
Added Benchmark project
Browse files Browse the repository at this point in the history
* Added Benchmark project to solution

* Added BenchmarkDotNet NuGet reference

* Added sample benchmark

---------

Co-authored-by: Marcin Przywóski <[email protected]>
  • Loading branch information
marcin-przywoski and Marcin Przywóski authored Aug 27, 2024
1 parent 2514f0c commit 266c33f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ExportViewer.Benchmarks/ExportViewer.Benchmarks.csproj
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.13.0" />
</ItemGroup>

</Project>
37 changes: 37 additions & 0 deletions ExportViewer.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

namespace ExportViewer.Benchmarks
{
public class Program
{
static void Main (string[] args)
{
var summary = BenchmarkRunner.Run<Program>();
}

private const string TestString = "Hello, World!";

[Benchmark]
public void UseStringBuilder ()
{
var sb = new System.Text.StringBuilder();
for (int i = 0; i < 1000; i++)
{
sb.Append(TestString);
}

_ = sb.ToString();
}

[Benchmark]
public void UseStringConcatenation ()
{
string result = "";
for (int i = 0; i < 1000; i++)
{
result += TestString;
}
}
}
}
14 changes: 14 additions & 0 deletions Facebook Export Viewer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExportViewer.Core", "Export
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExportViewer.Tests", "ExportViewer.Tests\ExportViewer.Tests.csproj", "{616AA5C5-DF52-4EE9-8D86-119D71417C2B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExportViewer.Benchmarks", "ExportViewer.Benchmarks\ExportViewer.Benchmarks.csproj", "{0C0D7A78-0F85-49EE-AC21-17B3995258B2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -65,6 +67,18 @@ Global
{616AA5C5-DF52-4EE9-8D86-119D71417C2B}.Release|x64.Build.0 = Release|x64
{616AA5C5-DF52-4EE9-8D86-119D71417C2B}.Release|x86.ActiveCfg = Release|x86
{616AA5C5-DF52-4EE9-8D86-119D71417C2B}.Release|x86.Build.0 = Release|x86
{0C0D7A78-0F85-49EE-AC21-17B3995258B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C0D7A78-0F85-49EE-AC21-17B3995258B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C0D7A78-0F85-49EE-AC21-17B3995258B2}.Debug|x64.ActiveCfg = Debug|Any CPU
{0C0D7A78-0F85-49EE-AC21-17B3995258B2}.Debug|x64.Build.0 = Debug|Any CPU
{0C0D7A78-0F85-49EE-AC21-17B3995258B2}.Debug|x86.ActiveCfg = Debug|Any CPU
{0C0D7A78-0F85-49EE-AC21-17B3995258B2}.Debug|x86.Build.0 = Debug|Any CPU
{0C0D7A78-0F85-49EE-AC21-17B3995258B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C0D7A78-0F85-49EE-AC21-17B3995258B2}.Release|Any CPU.Build.0 = Release|Any CPU
{0C0D7A78-0F85-49EE-AC21-17B3995258B2}.Release|x64.ActiveCfg = Release|Any CPU
{0C0D7A78-0F85-49EE-AC21-17B3995258B2}.Release|x64.Build.0 = Release|Any CPU
{0C0D7A78-0F85-49EE-AC21-17B3995258B2}.Release|x86.ActiveCfg = Release|Any CPU
{0C0D7A78-0F85-49EE-AC21-17B3995258B2}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 266c33f

Please sign in to comment.