generated from vignetteapp/dotnet-template
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmarking project for performance analysis
Will be useful later on as we cross-compare implementations when there's new improvements Signed-off-by: Ayane <[email protected]>
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
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
49 changes: 49 additions & 0 deletions
49
Mediapipe.Net.Benchmarks/FloatPacketPerformanceBenchmark.cs
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,49 @@ | ||
// Copyright (c) homuler and The Vignette Authors | ||
// This file is part of MediaPipe.NET. | ||
// MediaPipe.NET is licensed under the MIT License. See LICENSE for details. | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Engines; | ||
using BenchmarkDotNet.Running; | ||
using Mediapipe.Net.Framework.Packets; | ||
|
||
namespace Mediapipe.Net.Benchmarks | ||
{ | ||
[SimpleJob(RunStrategy.ColdStart, launchCount: 50)] | ||
[MinColumn, MaxColumn, MeanColumn, MedianColumn] | ||
public class FloatPacketPerformanceBenchmark | ||
{ | ||
|
||
[Benchmark] | ||
public void InstantiateFloatPacket() | ||
{ | ||
var randomSingle = new Random().NextSingle(); | ||
var packet = new FloatPacket(randomSingle); | ||
|
||
packet.ValidateAsType().Ok(); | ||
} | ||
|
||
[Benchmark] | ||
public void InstatiateFloatArrayPacket() | ||
{ | ||
var randomArray = new float[10]; | ||
for (var i = 0; i < randomArray.Length; i++) | ||
{ | ||
randomArray[i] = new Random().NextSingle(); | ||
} | ||
|
||
var packet = new FloatArrayPacket(randomArray); | ||
|
||
packet.ValidateAsType().Ok(); | ||
} | ||
|
||
} | ||
|
||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var summary = BenchmarkRunner.Run<FloatPacketPerformanceBenchmark>(); | ||
} | ||
} | ||
} |
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,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" /> | ||
<PackageReference Include="Mediapipe.Net.Runtime.CPU" Version="0.9.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Mediapipe.Net\Mediapipe.Net.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |