Skip to content

Commit

Permalink
feat: Add Snapshot Sample
Browse files Browse the repository at this point in the history
  • Loading branch information
workgroupengineering committed Oct 13, 2022
1 parent 662719c commit d8381b0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
<Reference Include="System.Reflection" />
</ItemGroup>
<ItemGroup>
<None Remove="snapshot.js" />
</ItemGroup>
<ItemGroup>
<Content Include="snapshot.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="System.Drawing.Common" Version="4.5.1" />
<PackageReference Include="System.Memory" Version="4.5.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\BenchmarkDotNet.Snapshot\BenchmarkDotNet.Snapshot.csproj" />
<ProjectReference Include="..\..\src\BenchmarkDotNet\BenchmarkDotNet.csproj" />
<ProjectReference Include="..\..\src\BenchmarkDotNet.Diagnostics.Windows\BenchmarkDotNet.Diagnostics.Windows.csproj" />
</ItemGroup>
Expand Down
32 changes: 32 additions & 0 deletions samples/BenchmarkDotNet.Samples/IntroSnapshot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Toolchains.Snapshot;
using System.Threading;

namespace BenchmarkDotNet.Samples
{
[Config(typeof(Config))]
public class IntroSnapshot
{
private class Config : ManualConfig
{
public Config()
{
var store = Toolchains.Snapshot.Stores.JsonShanpshotStore.From("./snapshot.js");
var toolchain = SnapshotToolchain.From(store);
AddJob(Job.Default.WithToolchain(toolchain).WithBaseline(true).WithId("Baseline"));
AddJob(Job.ShortRun);
AddExporter(SnapshotExporter.From(store));
}
}
// And define a method with the Benchmark attribute
[Benchmark]
public void Sleep() => Thread.Sleep(10);

// You can write a description for your method.
[Benchmark(Description = "Thread.Sleep(15)")]
public void SleepWithDescription() => Thread.Sleep(15);
}
}
1 change: 1 addition & 0 deletions samples/BenchmarkDotNet.Samples/snapshot.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d8381b0

Please sign in to comment.