summaryrefslogtreecommitdiff
path: root/Runtime/Testing/JobSchedulerTest
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Testing/JobSchedulerTest')
-rw-r--r--Runtime/Testing/JobSchedulerTest/Test.sln21
-rw-r--r--Runtime/Testing/JobSchedulerTest/Test.vcproj162
-rw-r--r--Runtime/Testing/JobSchedulerTest/main.cpp82
3 files changed, 265 insertions, 0 deletions
diff --git a/Runtime/Testing/JobSchedulerTest/Test.sln b/Runtime/Testing/JobSchedulerTest/Test.sln
new file mode 100644
index 0000000..c6f9aa5
--- /dev/null
+++ b/Runtime/Testing/JobSchedulerTest/Test.sln
@@ -0,0 +1,21 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcproj", "{4FB80099-804E-4ABE-9680-31290A6F0D89}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {4FB80099-804E-4ABE-9680-31290A6F0D89}.Debug.ActiveCfg = Debug|Win32
+ {4FB80099-804E-4ABE-9680-31290A6F0D89}.Debug.Build.0 = Debug|Win32
+ {4FB80099-804E-4ABE-9680-31290A6F0D89}.Release.ActiveCfg = Release|Win32
+ {4FB80099-804E-4ABE-9680-31290A6F0D89}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Runtime/Testing/JobSchedulerTest/Test.vcproj b/Runtime/Testing/JobSchedulerTest/Test.vcproj
new file mode 100644
index 0000000..58b742f
--- /dev/null
+++ b/Runtime/Testing/JobSchedulerTest/Test.vcproj
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="windows-1257"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="Test"
+ ProjectGUID="{4FB80099-804E-4ABE-9680-31290A6F0D89}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="build/debug"
+ IntermediateDirectory="build/debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=".;..;..\..\Utilities;..\..\Threads"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="Test_d.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/Test.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="build/release"
+ IntermediateDirectory="build/release"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=".;..;..\..\Utilities;..\..\Threads"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="Test.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="unity"
+ Filter="">
+ <File
+ RelativePath="..\..\Threads\JobScheduler.cpp">
+ </File>
+ <File
+ RelativePath="..\..\Threads\JobScheduler.h">
+ </File>
+ <File
+ RelativePath="..\..\Utilities\Mutex.cpp">
+ </File>
+ <File
+ RelativePath="..\..\Utilities\Mutex.h">
+ </File>
+ <File
+ RelativePath="..\..\Threads\Semaphore.h">
+ </File>
+ <File
+ RelativePath="..\..\Utilities\Thread.cpp">
+ </File>
+ <File
+ RelativePath="..\..\Utilities\Thread.h">
+ </File>
+ <File
+ RelativePath="..\..\Threads\ThreadMessageQueue.cpp">
+ </File>
+ <File
+ RelativePath="..\..\Threads\ThreadMessageQueue.h">
+ </File>
+ <File
+ RelativePath="..\..\Threads\ThreadUtility.h">
+ </File>
+ <File
+ RelativePath="..\..\Utilities\Word.cpp">
+ </File>
+ <File
+ RelativePath="..\..\Utilities\Word.h">
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\main.cpp">
+ </File>
+ <File
+ RelativePath="..\UnityPrefix.h">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Runtime/Testing/JobSchedulerTest/main.cpp b/Runtime/Testing/JobSchedulerTest/main.cpp
new file mode 100644
index 0000000..8554107
--- /dev/null
+++ b/Runtime/Testing/JobSchedulerTest/main.cpp
@@ -0,0 +1,82 @@
+#include <cstdio>
+#include <cstdlib>
+#include "UnityPrefix.h"
+#include "Runtime/Threads/Thread.h"
+#include "Runtime/Threads/Mutex.h"
+#include "Runtime/Threads/JobScheduler.h"
+#include <time.h>
+#include <math.h>
+
+struct WorkData {
+ float input;
+ float output;
+};
+
+void* WorkFunction( void* data )
+{
+ WorkData* d = (WorkData*)data;
+ d->output = 0.0f;
+ for( int i = 0; i < 1000000; ++i ) {
+ d->output += sinf(d->output) + cosf(d->input) - sinf(d->output + d->input * 3.0f);
+ }
+
+ return NULL;
+}
+
+// Windows, Core2Quad 2.40
+// 200 jobs, 100000 iters:
+// Sum=590573.192871
+// 0=1.55s 1=0.80s 2=0.55s 3=0.45s 4=0.45s 5=0.44s 6=0.45s
+// 100 jobs, 1000000 iters:
+// Sum=2992744.398470
+// 0=7.78s 1=3.94s 2=2.66s 3=2.00s 4=2.00s 5=2.00s 6=2.02s
+
+void DoTests()
+{
+ JobScheduler scheduler(3,1);
+
+ JobScheduler::JobGroupID group = scheduler.BeginGroup();
+
+ const int kJobs = 100;
+ WorkData datas[kJobs];
+ for( int i = 0; i < kJobs; ++i )
+ {
+ datas[i].input = i+1;
+ scheduler.SubmitJob( group, WorkFunction, &datas[i], NULL );
+ }
+ scheduler.WaitForGroup(group);
+
+ float sum = 0.0f;
+ for( int i = 0; i < kJobs; ++i )
+ sum += datas[i].output;
+ printf("Sum of results: %f\n", sum);
+}
+
+
+
+int main()
+{
+ #if UNITY_WIN
+ DWORD ttt0 = GetTickCount();
+ #else
+ timeval ttt0;
+ gettimeofday( &ttt0, NULL );
+ #endif
+
+ DoTests();
+
+ #if UNITY_WIN
+ DWORD ttt1 = GetTickCount();
+ float timeTaken = (ttt1-ttt0) * 0.001f;
+ #else
+ timeval ttt1;
+ gettimeofday( &ttt1, NULL );
+ timeval ttt2;
+ timersub( &ttt1, &ttt0, &ttt2 );
+ float timeTaken = ttt2.tv_sec + ttt2.tv_usec * 1.0e-6f;
+ #endif
+
+ printf( "Test time: %.2fs\n", timeTaken );
+
+ return 0;
+}