Skip to content

Commit

Permalink
Update benchmark projects (#2130)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow authored Jun 28, 2022
1 parent 45cfd16 commit cb424e5
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tools/
*.VC.db
**/Resources/Resource.designer.cs
*.binlog
**/BenchmarkDotNet.Artifacts/

# User-specific files
*.suo
Expand Down
30 changes: 30 additions & 0 deletions benchmarks/SkiaSharp.Benchmarks/Benchmarks/Benchmarks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Buffers;
using System.IO;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnostics.Windows.Configs;
using BenchmarkDotNet.Jobs;

namespace SkiaSharp.Benchmarks;

[EtwProfiler]
// [NativeMemoryProfiler]
[MemoryDiagnoser]
// [SimpleJob(RuntimeMoniker.Mono)]
// [SimpleJob(RuntimeMoniker.Net472)]
// [SimpleJob(RuntimeMoniker.NetCoreApp31)]
[SimpleJob(RuntimeMoniker.Net60)]
public class Benchmark
{
[GlobalSetup]
public void GlobalSetup()
{

}

[Benchmark]
public void TheBenchmark()
{

}
}
33 changes: 6 additions & 27 deletions benchmarks/SkiaSharp.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Running;

namespace SkiaSharp.Benchmarks
{
//[SimpleJob(RuntimeMoniker.CoreRt31)]
[SimpleJob(RuntimeMoniker.Mono)]
[SimpleJob(RuntimeMoniker.Net472)]
[SimpleJob(RuntimeMoniker.NetCoreApp31)]
public class Benchmark
{
public Benchmark()
{
// setup
}
namespace SkiaSharp.Benchmarks;

[Benchmark]
public void TheBenchmark()
{
// benchmark
}
}

public class Program
public class Program
{
public static void Main(string[] args)
{
public static void Main(string[] args)
{
var summary = BenchmarkRunner.Run<Benchmark>();
}
var summary = BenchmarkRunner.Run<Benchmark>();
}
}
36 changes: 18 additions & 18 deletions benchmarks/SkiaSharp.Benchmarks/SkiaSharp.Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net472;netcoreapp3.1;net6.0</TargetFrameworks>
<RootNamespace>SkiaSharp.Benchmarks</RootNamespace>
<AssemblyName>SkiaSharp.Benchmarks</AssemblyName>
<SkipGenerateAssemblyVersionInfo>true</SkipGenerateAssemblyVersionInfo>
<SkipMDocGenerateDocs>true</SkipMDocGenerateDocs>
<SkipCopyToOutputDirectory>true</SkipCopyToOutputDirectory>
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\binding\HarfBuzzSharp\HarfBuzzSharp.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.SceneGraph\SkiaSharp.SceneGraph.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp.Skottie\SkiaSharp.Skottie.csproj" />
<ProjectReference Include="..\..\binding\SkiaSharp\SkiaSharp.csproj" />
<ProjectReference Include="..\..\source\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz\SkiaSharp.HarfBuzz.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\output\native\windows\x64\libSkiaSharp.dll" CopyToOutputDirectory="Always" Visible="false"
Condition=" Exists('..\..\output\native\windows\x64\libSkiaSharp.dll') or '$(IsWindows)' == 'true' " />
<Content Include="..\..\output\native\windows\x64\libSkiaSharp.pdb" CopyToOutputDirectory="Always" Visible="false"
Condition=" Exists('..\..\output\native\windows\x64\libSkiaSharp.pdb') or '$(IsWindows)' == 'true' " />
<Content Include="..\..\output\native\windows\x64\libHarfBuzzSharp.dll" CopyToOutputDirectory="Always" Visible="false"
Condition=" Exists('..\..\output\native\windows\x64\libHarfBuzzSharp.dll') or '$(IsWindows)' == 'true' " />
<Content Include="..\..\output\native\windows\x64\libHarfBuzzSharp.pdb" CopyToOutputDirectory="Always" Visible="false"
Condition=" Exists('..\..\output\native\windows\x64\libHarfBuzzSharp.pdb') or '$(IsWindows)' == 'true' " />
<Content Include="..\..\output\native\osx\libSkiaSharp.dylib" CopyToOutputDirectory="Always" Visible="false"
Condition=" Exists('..\..\output\native\osx\libSkiaSharp.dylib') or '$(IsMacOS)' == 'true' " />
<Content Include="..\..\output\native\osx\libHarfBuzzSharp.dylib" CopyToOutputDirectory="Always" Visible="false"
Condition=" Exists('..\..\output\native\osx\libHarfBuzzSharp.dylib') or '$(IsMacOS)' == 'true' " />
<Content Include="..\..\output\native\linux\x64\libSkiaSharp.so" CopyToOutputDirectory="Always" Visible="false"
Condition=" Exists('..\..\output\native\linux\x64\libSkiaSharp.so') or '$(IsLinux)' == 'true' " />
<Content Include="..\..\output\native\linux\x64\libHarfBuzzSharp.so" CopyToOutputDirectory="Always" Visible="false"
Condition=" Exists('..\..\output\native\linux\x64\libHarfBuzzSharp.so') or '$(IsLinux)' == 'true' " />
<Content Include="..\..\output\native\windows\x64\libSkiaSharp.dll" CopyToOutputDirectory="Always" Visible="false" Condition=" Exists('..\..\output\native\windows\x64\libSkiaSharp.dll') or '$(IsWindows)' == 'true' " />
<Content Include="..\..\output\native\windows\x64\libSkiaSharp.pdb" CopyToOutputDirectory="Always" Visible="false" Condition=" Exists('..\..\output\native\windows\x64\libSkiaSharp.pdb') or '$(IsWindows)' == 'true' " />
<Content Include="..\..\output\native\windows\x64\libHarfBuzzSharp.dll" CopyToOutputDirectory="Always" Visible="false" Condition=" Exists('..\..\output\native\windows\x64\libHarfBuzzSharp.dll') or '$(IsWindows)' == 'true' " />
<Content Include="..\..\output\native\windows\x64\libHarfBuzzSharp.pdb" CopyToOutputDirectory="Always" Visible="false" Condition=" Exists('..\..\output\native\windows\x64\libHarfBuzzSharp.pdb') or '$(IsWindows)' == 'true' " />
<Content Include="..\..\output\native\osx\libSkiaSharp.dylib" CopyToOutputDirectory="Always" Visible="false" Condition=" Exists('..\..\output\native\osx\libSkiaSharp.dylib') or '$(IsMacOS)' == 'true' " />
<Content Include="..\..\output\native\osx\libHarfBuzzSharp.dylib" CopyToOutputDirectory="Always" Visible="false" Condition=" Exists('..\..\output\native\osx\libHarfBuzzSharp.dylib') or '$(IsMacOS)' == 'true' " />
<Content Include="..\..\output\native\linux\x64\libSkiaSharp.so" CopyToOutputDirectory="Always" Visible="false" Condition=" Exists('..\..\output\native\linux\x64\libSkiaSharp.so') or '$(IsLinux)' == 'true' " />
<Content Include="..\..\output\native\linux\x64\libHarfBuzzSharp.so" CopyToOutputDirectory="Always" Visible="false" Condition=" Exists('..\..\output\native\linux\x64\libHarfBuzzSharp.so') or '$(IsLinux)' == 'true' " />
</ItemGroup>
<ItemGroup>
<None Remove="BenchmarkDotNet.Artifacts/**" />
</ItemGroup>
</Project>
16 changes: 14 additions & 2 deletions benchmarks/SkiaSharp.Benchmarks/SkiaSharp.Benchmarks.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29102.215
# Visual Studio Version 17
VisualStudioVersion = 17.3.32611.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp", "..\..\binding\SkiaSharp\SkiaSharp.csproj", "{3E1B158B-6C3B-4340-9F01-28E77D24F31D}"
EndProject
Expand All @@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.HarfBuzz", "..\..
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Benchmarks", "SkiaSharp.Benchmarks.csproj", "{8E5284C3-5AAF-4902-B12F-84E9172F20E0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.SceneGraph", "..\..\binding\SkiaSharp.SceneGraph\SkiaSharp.SceneGraph.csproj", "{42B5D998-A676-4B50-B558-1D3ACA7D3FC4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkiaSharp.Skottie", "..\..\binding\SkiaSharp.Skottie\SkiaSharp.Skottie.csproj", "{DD03EAA1-A85D-4588-8B84-8285EC1979C8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -33,6 +37,14 @@ Global
{8E5284C3-5AAF-4902-B12F-84E9172F20E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E5284C3-5AAF-4902-B12F-84E9172F20E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E5284C3-5AAF-4902-B12F-84E9172F20E0}.Release|Any CPU.Build.0 = Release|Any CPU
{42B5D998-A676-4B50-B558-1D3ACA7D3FC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{42B5D998-A676-4B50-B558-1D3ACA7D3FC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42B5D998-A676-4B50-B558-1D3ACA7D3FC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{42B5D998-A676-4B50-B558-1D3ACA7D3FC4}.Release|Any CPU.Build.0 = Release|Any CPU
{DD03EAA1-A85D-4588-8B84-8285EC1979C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD03EAA1-A85D-4588-8B84-8285EC1979C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD03EAA1-A85D-4588-8B84-8285EC1979C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD03EAA1-A85D-4588-8B84-8285EC1979C8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
39 changes: 39 additions & 0 deletions benchmarks/SkiaSharp.Benchmarks/Utils/NonSeekableReadOnlyStream.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.IO;

namespace SkiaSharp.Benchmarks;

public class NonSeekableReadOnlyStream : Stream
{
private readonly Stream stream;

public NonSeekableReadOnlyStream(Stream stream)
{
this.stream = stream;
}

public override bool CanRead => stream.CanRead;

public override bool CanSeek => false;

public override bool CanWrite => false;

public override long Length => throw new NotSupportedException();

public override long Position
{
get => stream.Position;
set => throw new NotSupportedException();
}

public override void Flush() => throw new NotSupportedException();

public override int Read(byte[] buffer, int offset, int count) =>
stream.Read(buffer, offset, count);

public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();

public override void SetLength(long value) => throw new NotSupportedException();

public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
"dafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef00" +
"65d016df")]

[assembly: InternalsVisibleTo("SkiaSharp.Benchmarks, PublicKey=" +
"002400000480000094000000060200000024000052534131000400000100010079159977d2d03a" +
"8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c" +
"3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fd" +
"dafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef00" +
"65d016df")]

[assembly: AssemblyMetadata("IsTrimmable", "True")]

#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACOS__
Expand Down
6 changes: 6 additions & 0 deletions source/SkiaSharp.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
<Net6PlatformTargetFrameworks Condition="$(IsNet6TizenSupported)">$(Net6PlatformTargetFrameworks);net6.0-tizen</Net6PlatformTargetFrameworks>
</PropertyGroup>

<!-- Special case for SkiaSharp.Benchmarks -->
<PropertyGroup Condition="'$(SolutionName)' == 'SkiaSharp.Benchmarks' or '$(IsBenchmarks)' == 'true' or $(MSBuildStartupDirectory.Contains('benchmarks\SkiaSharp.Benchmarks'))">
<BasicTargetFrameworks>net462;netcoreapp3.1</BasicTargetFrameworks>
<Net6PlatformTargetFrameworks>net6.0</Net6PlatformTargetFrameworks>
</PropertyGroup>

<!-- Base TFMs for the core parts -->
<PropertyGroup>
<AllTargetFrameworks>$(BasicTargetFrameworks)</AllTargetFrameworks>
Expand Down

0 comments on commit cb424e5

Please sign in to comment.