Skip to content

Commit f75f356

Browse files
committed
Add benchmarks
1 parent fa51a38 commit f75f356

File tree

5 files changed

+65
-13
lines changed

5 files changed

+65
-13
lines changed

OVRSharp.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OVRSharp.Graphics.DirectX",
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OVRSharp.Graphics.DirectX.Tests", "tests\OVRSharp.Graphics.DirectX.Tests\OVRSharp.Graphics.DirectX.Tests.csproj", "{80860435-8D24-48BB-BA3A-25ECB6AA6E0A}"
1919
EndProject
20-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OVRSharp.Tests", "tests\OVRSharp.Tests\OVRSharp.Tests.csproj", "{875527A2-DDD3-4F4B-A0EF-4F7980D6AB73}"
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OVRSharp.Tests", "tests\OVRSharp.Tests\OVRSharp.Tests.csproj", "{875527A2-DDD3-4F4B-A0EF-4F7980D6AB73}"
21+
EndProject
22+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OVRSharp.Benchmarks", "tests\OVRSharp.Benchmarks\OVRSharp.Benchmarks.csproj", "{5CF4140D-F0E4-4F9D-8DEC-92F3DD82720F}"
2123
EndProject
2224
Global
2325
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -49,6 +51,10 @@ Global
4951
{875527A2-DDD3-4F4B-A0EF-4F7980D6AB73}.Debug|Any CPU.Build.0 = Debug|Any CPU
5052
{875527A2-DDD3-4F4B-A0EF-4F7980D6AB73}.Release|Any CPU.ActiveCfg = Release|Any CPU
5153
{875527A2-DDD3-4F4B-A0EF-4F7980D6AB73}.Release|Any CPU.Build.0 = Release|Any CPU
54+
{5CF4140D-F0E4-4F9D-8DEC-92F3DD82720F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55+
{5CF4140D-F0E4-4F9D-8DEC-92F3DD82720F}.Debug|Any CPU.Build.0 = Debug|Any CPU
56+
{5CF4140D-F0E4-4F9D-8DEC-92F3DD82720F}.Release|Any CPU.ActiveCfg = Release|Any CPU
57+
{5CF4140D-F0E4-4F9D-8DEC-92F3DD82720F}.Release|Any CPU.Build.0 = Release|Any CPU
5258
EndGlobalSection
5359
GlobalSection(SolutionProperties) = preSolution
5460
HideSolutionNode = FALSE
@@ -60,6 +66,7 @@ Global
6066
{AF840E83-0D65-4558-8086-F19491B4532B} = {EDA24C40-CE58-429D-A903-19BDE6D024E6}
6167
{80860435-8D24-48BB-BA3A-25ECB6AA6E0A} = {AC203731-548C-4C7D-95BD-AAA6D7D288FC}
6268
{875527A2-DDD3-4F4B-A0EF-4F7980D6AB73} = {AC203731-548C-4C7D-95BD-AAA6D7D288FC}
69+
{5CF4140D-F0E4-4F9D-8DEC-92F3DD82720F} = {AC203731-548C-4C7D-95BD-AAA6D7D288FC}
6370
EndGlobalSection
6471
GlobalSection(ExtensibilityGlobals) = postSolution
6572
SolutionGuid = {93984CAB-8CA9-430A-8166-5E2B339CA8A8}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using NBench;
2+
using OVRSharp.Graphics.DirectX;
3+
4+
namespace OVRSharp.Benchmarks.Graphics
5+
{
6+
public class CompositorBenchmarks
7+
{
8+
[PerfSetup]
9+
public void Setup()
10+
{
11+
var app = new Application(Application.ApplicationType.Background);
12+
}
13+
14+
[PerfBenchmark(
15+
RunMode = RunMode.Iterations,
16+
NumberOfIterations = 100,
17+
TestMode = TestMode.Measurement
18+
)]
19+
[TimingMeasurement()]
20+
[MemoryMeasurement(MemoryMetric.TotalBytesAllocated)]
21+
public void GetMirrorImageBenchmark()
22+
{
23+
DirectXCompositor.Instance.GetMirrorImage();
24+
}
25+
}
26+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net5.0</TargetFramework>
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="NBench" Version="2.0.1" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\..\OVRSharp.Graphics.DirectX\OVRSharp.Graphics.DirectX.csproj" />
15+
<ProjectReference Include="..\..\OVRSharp.Graphics.OpenGL\OVRSharp.Graphics.OpenGL.csproj" />
16+
<ProjectReference Include="..\..\OVRSharp\OVRSharp.csproj" />
17+
</ItemGroup>
18+
19+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using NBench;
2+
3+
namespace OVRSharp.Benchmarks
4+
{
5+
class Program
6+
{
7+
static int Main()
8+
{
9+
return NBenchRunner.Run<Program>();
10+
}
11+
}
12+
}

tests/OVRSharp.Tests/Graphics/CompositorTests.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,5 @@ public void ShouldGetMirrorTextureSuccessfully(EVREye eye)
5656
bitmap.Height.Should().BeGreaterThan(0);
5757
bitmap.Width.Should().BeGreaterThan(0);
5858
}
59-
60-
// This test is mostly here to make sure we are deallocating resources properly.
61-
[Test]
62-
public void ShouldWorkWhenCalledRapidly()
63-
{
64-
for (var i = 0; i < 100; i++)
65-
{
66-
var bitmap = compositor.GetMirrorImage(EVREye.Eye_Left);
67-
bitmap.Height.Should().BeGreaterThan(0);
68-
bitmap.Width.Should().BeGreaterThan(0);
69-
}
70-
}
7159
}
7260
}

0 commit comments

Comments
 (0)