Skip to content

Commit

Permalink
Add benchmarking test project and add text drawing benchmark tests (#…
Browse files Browse the repository at this point in the history
…1876)

Creates a new test project Benchmark in the Unit Test group, which leverages GTest to run automated benchmark tests. Simple tests can be done with the TEST_BENCHMARK macro, or more complex ones can be used by creating classes to do setup and teardown so only specific parts of code are measured.
  • Loading branch information
aballway authored Feb 3, 2017
1 parent c740efc commit d69e26a
Show file tree
Hide file tree
Showing 9 changed files with 1,304 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Frameworks/include/CppUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ std::basic_ostream<T>& operator<<(std::basic_ostream<T>& os, const CGSize& size)
return os;
}

inline CGSize operator*(const CGSize& lhs, CGFloat multiplier) {
return{ lhs.width * multiplier, lhs.height * multiplier };
}

#pragma endregion

#pragma region CGRect
Expand Down
248 changes: 248 additions & 0 deletions build/Tests/Benchmark/Framework.Benchmark.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Foundation\dll\Foundation.vcxproj">
<Project>{86127226-9A6E-439B-A070-420A572AF0C7}</Project>
</ProjectReference>
<ProjectReference Include="..\..\CoreFoundation\dll\CoreFoundation.vcxproj">
<Project>{81F30AF6-EAC3-4DFA-929A-C25D69E8080B}</Project>
</ProjectReference>
<ProjectReference Include="..\..\Logging\dll\Logging.vcxproj">
<Project>{862d36c2-cc83-4d04-b9b8-bef07f479905}</Project>
</ProjectReference>
<ProjectReference Include="..\..\Starboard\dll\Starboard.vcxproj">
<Project>{0AC27ECF-E2AB-420B-9359-4843FFF4CBFA}</Project>
</ProjectReference>
<ProjectReference Include="..\..\UIKit\dll\UIKit.vcxproj">
<Project>{8E79930B-7EF6-4A4E-B46C-EFC0A49C55D9}</Project>
</ProjectReference>
<ProjectReference Include="..\..\CoreGraphics\dll\CoreGraphics.vcxproj">
<Project>{26da08da-d0b9-4579-b168-e7f0a5f20e57}</Project>
</ProjectReference>
<ProjectReference Include="..\..\CoreText\dll\CoreText.vcxproj">
<Project>{36deec5d-f77b-4c94-a63c-86fb716833de}</Project>
</ProjectReference>
<ProjectReference Include="..\..\WinObjCRT\dll\WinObjCRT.vcxproj">
<Project>{585b4870-0d6b-43a6-8e7e-ad08f7f507b6}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\debugger_general.xml" />
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\debugger_local_windows.xml" />
</ItemGroup>
<PropertyGroup Label="Globals">
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<ProjectGuid>{7A062AEC-5AED-4F83-8716-4C078F75177B}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Framework.Benchmark</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<ApplicationType>Windows Store</ApplicationType>
<AppContainerApplication>false</AppContainerApplication>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.10586.0</WindowsTargetPlatformMinVersion>
<WindowsAppContainer>false</WindowsAppContainer>
<TargetOsAndVersion>Universal Windows</TargetOsAndVersion>
<StarboardBasePath>..\..\..</StarboardBasePath>
<UseStarboardSourceSdk>true</UseStarboardSourceSdk>
<IslandwoodDRT>false</IslandwoodDRT>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace)\</OutDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(StarboardBasePath)\msvc\starboard-cmdline.props" />
</ImportGroup>
<ImportGroup Label="ExtensionSettings">
<Import Project="$(StarboardBasePath)\msvc\ut-build.props" />
</ImportGroup>
<ImportGroup Label="Shared">
<Import Project="..\Tests.Shared\Tests.Shared.vcxitems" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>NO_STUBS;WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(StarboardBasePath)\tests\frameworks\include;$(StarboardBasePath)\tests\frameworks\gtest;$(StarboardBasePath)\tests\frameworks\gtest\include;$(MSBuildThisFileDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libdispatch.lib;mincore.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AppContainer>false</AppContainer>
</Link>
<ClangCompile>
<IncludePaths>$(StarboardBasePath)\Frameworks\include;$(StarboardBasePath)\include\xplat;$(StarboardBasePath)\tests\frameworks\include;$(StarboardBasePath)\tests\frameworks\gtest;$(StarboardBasePath)\tests\frameworks\gtest\include;$(StarboardBasePath)\;%(AdditionalIncludeDirectories)</IncludePaths>
<CompileAs>CompileAsObjCpp</CompileAs>
<OtherCPlusPlusFlags>-fmsvc-real-char -Wdeprecated-declarations</OtherCPlusPlusFlags>
<PreprocessorDefinitions>NO_STUBS;_CRT_SECURE_NO_WARNINGS;DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClangCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>NO_STUBS;WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(StarboardBasePath)\tests\frameworks\include;$(StarboardBasePath)\tests\frameworks\gtest;$(StarboardBasePath)\tests\frameworks\gtest\include;$(MSBuildThisFileDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libdispatch.lib;mincore.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AppContainer>false</AppContainer>
</Link>
<ClangCompile>
<IncludePaths>$(StarboardBasePath)\Frameworks\include;$(StarboardBasePath)\include\xplat;$(StarboardBasePath)\tests\frameworks\include;$(StarboardBasePath)\tests\frameworks\gtest;$(StarboardBasePath)\tests\frameworks\gtest\include;$(StarboardBasePath)\;%(AdditionalIncludeDirectories)</IncludePaths>
<CompileAs>CompileAsObjCpp</CompileAs>
<OtherCPlusPlusFlags>-fmsvc-real-char -Wdeprecated-declarations</OtherCPlusPlusFlags>
<PreprocessorDefinitions>NO_STUBS;_CRT_SECURE_NO_WARNINGS;DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClangCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NO_STUBS;WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(StarboardBasePath)\tests\frameworks\include;$(StarboardBasePath)\tests\frameworks\gtest;$(StarboardBasePath)\tests\frameworks\gtest\include;$(MSBuildThisFileDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libdispatch.lib;mincore.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AppContainer>false</AppContainer>
</Link>
<ClangCompile>
<IncludePaths>$(StarboardBasePath)\Frameworks\include;$(StarboardBasePath)\include\xplat;$(StarboardBasePath)\tests\frameworks\include;$(StarboardBasePath)\tests\frameworks\gtest;$(StarboardBasePath)\tests\frameworks\gtest\include;$(StarboardBasePath)\;%(AdditionalIncludeDirectories)</IncludePaths>
<CompileAs>CompileAsObjCpp</CompileAs>
<OtherCPlusPlusFlags>-fmsvc-real-char</OtherCPlusPlusFlags>
<PreprocessorDefinitions>NO_STUBS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClangCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NO_STUBS;WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(StarboardBasePath)\tests\frameworks\include;$(StarboardBasePath)\tests\frameworks\gtest;$(StarboardBasePath)\tests\frameworks\gtest\include;$(MSBuildThisFileDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libdispatch.lib;mincore.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AppContainer>false</AppContainer>
</Link>
<ClangCompile>
<IncludePaths>$(StarboardBasePath)\Frameworks\include;$(StarboardBasePath)\include\xplat;$(StarboardBasePath)\tests\frameworks\include;$(StarboardBasePath)\tests\frameworks\gtest;$(StarboardBasePath)\tests\frameworks\gtest\include;$(StarboardBasePath)\;%(AdditionalIncludeDirectories)</IncludePaths>
<CompileAs>CompileAsObjCpp</CompileAs>
<OtherCPlusPlusFlags>-fmsvc-real-char</OtherCPlusPlusFlags>
<PreprocessorDefinitions>NO_STUBS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClangCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="$(StarboardBasePath)\tests\UnitTests\Framework\Framework.cpp" />
<ClCompile Include="$(StarboardBasePath)\tests\Benchmark\EntryPoint.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(StarboardBasePath)\tests\Benchmark\Benchmark.h" />
<ClInclude Include="$(StarboardBasePath)\tests\Benchmark\BenchmarkPublisher.h" />
</ItemGroup>
<ItemGroup>
<ClangCompile Include="$(StarboardBasePath)\tests\Benchmark\BenchmarkSampleTests.mm" />
<ClangCompile Include="$(StarboardBasePath)\tests\Benchmark\TextBenchmarkTests.mm" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(StarboardBasePath)\msvc\starboard-cmdline.targets" />
</ImportGroup>
</Project>
14 changes: 14 additions & 0 deletions build/build.sln
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AddressBook.UnitTests", "Te
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreGraphics.Drawing.UnitTests", "Tests\UnitTests\CoreGraphics.Drawing\CoreGraphics.Drawing.UnitTests.vcxproj", "{DE51CDE9-F326-49B6-8C5B-35D5B091878C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmark", "Benchmark", "{99A75321-675A-4C92-9848-96D3C8460625}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Framework.Benchmark", "Tests\Benchmark\Framework.Benchmark.vcxproj", "{7A062AEC-5AED-4F83-8716-4C078F75177B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Expand Down Expand Up @@ -1963,6 +1967,14 @@ Global
{DE51CDE9-F326-49B6-8C5B-35D5B091878C}.Release|ARM.Build.0 = Release|ARM
{DE51CDE9-F326-49B6-8C5B-35D5B091878C}.Release|x86.ActiveCfg = Release|Win32
{DE51CDE9-F326-49B6-8C5B-35D5B091878C}.Release|x86.Build.0 = Release|Win32
{7A062AEC-5AED-4F83-8716-4C078F75177B}.Debug|ARM.ActiveCfg = Debug|ARM
{7A062AEC-5AED-4F83-8716-4C078F75177B}.Debug|ARM.Build.0 = Debug|ARM
{7A062AEC-5AED-4F83-8716-4C078F75177B}.Debug|x86.ActiveCfg = Debug|Win32
{7A062AEC-5AED-4F83-8716-4C078F75177B}.Debug|x86.Build.0 = Debug|Win32
{7A062AEC-5AED-4F83-8716-4C078F75177B}.Release|ARM.ActiveCfg = Release|ARM
{7A062AEC-5AED-4F83-8716-4C078F75177B}.Release|ARM.Build.0 = Release|ARM
{7A062AEC-5AED-4F83-8716-4C078F75177B}.Release|x86.ActiveCfg = Release|Win32
{7A062AEC-5AED-4F83-8716-4C078F75177B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2264,5 +2276,7 @@ Global
{69D1F829-1843-4395-BCE9-69C4CEB59004} = {88413F6C-C27A-4B48-9AE5-D36161920F6D}
{62E53898-65C2-4401-BF58-FBFB728E1B27} = {69D1F829-1843-4395-BCE9-69C4CEB59004}
{DE51CDE9-F326-49B6-8C5B-35D5B091878C} = {0A79AFE5-2685-433C-BC78-A4AD09CD7BF8}
{99A75321-675A-4C92-9848-96D3C8460625} = {58128019-F022-44F1-9D59-811230051CD8}
{7A062AEC-5AED-4F83-8716-4C078F75177B} = {99A75321-675A-4C92-9848-96D3C8460625}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion include/CoreGraphics/CGContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ COREGRAPHICS_EXPORT void CGContextShowGlyphs(CGContextRef c, const CGGlyph* g, s
COREGRAPHICS_EXPORT void CGContextShowGlyphsAtPoint(CGContextRef c, CGFloat x, CGFloat y, const CGGlyph* glyphs, size_t count);
COREGRAPHICS_EXPORT void CGContextShowGlyphsWithAdvances(CGContextRef c, const CGGlyph* glyphs, const CGSize* advances, size_t count);

COREGRAPHICS_EXPORT void CGContextShowGlyphsAtPositions(CGContextRef c, const CGGlyph* glyphs, const CGPoint* Lpositions, size_t count)
COREGRAPHICS_EXPORT void CGContextShowGlyphsAtPositions(CGContextRef c, const CGGlyph* glyphs, const CGPoint* positions, size_t count)
STUB_METHOD;

COREGRAPHICS_EXPORT CGAffineTransform CGContextGetTextMatrix(CGContextRef c);
Expand Down
Loading

0 comments on commit d69e26a

Please sign in to comment.