summaryrefslogtreecommitdiffstats
path: root/Tests/NoiseTest
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Tests/NoiseTest/NoiseTest.cpp202
-rw-r--r--Tests/NoiseTest/NoiseTest.sln40
-rw-r--r--Tests/NoiseTest/NoiseTest.vcproj516
3 files changed, 379 insertions, 379 deletions
diff --git a/Tests/NoiseTest/NoiseTest.cpp b/Tests/NoiseTest/NoiseTest.cpp
index eae024f2f..5542f3ca6 100644
--- a/Tests/NoiseTest/NoiseTest.cpp
+++ b/Tests/NoiseTest/NoiseTest.cpp
@@ -1,101 +1,101 @@
-
-// NoiseTest.cpp
-
-// Implements the main app entrypoint
-
-#include "Globals.h"
-#include <time.h>
-#include "Noise.h"
-
-
-
-
-
-void SaveValues(NOISE_DATATYPE * a_Values, const AString & a_FileName)
-{
- cFile f;
- if (!f.Open(a_FileName, cFile::fmWrite))
- {
- LOGWARNING("Cannot write file %s", a_FileName.c_str());
- return;
- }
- for (int y = 0; y < 256; y++)
- {
- unsigned char val[256];
- for (int x = 0; x < 256; x++)
- {
- val[x] = std::min(255, std::max(0, (int)(256 * a_Values[x + 256 * y])));
- }
- f.Write(val, 256);
- }
-}
-
-
-
-
-
-clock_t TestCubicNoise(void)
-{
- cCubicNoise Cubic(0);
- NOISE_DATATYPE Values[256 * 256];
-
- // Do a speed test:
- clock_t Begin = clock();
- for (int i = 0; i < 1000; i++)
- {
- Cubic.Generate2D(Values, 256, 256, 0, (NOISE_DATATYPE)25.6, 0, (NOISE_DATATYPE)25.6);
- }
- clock_t Ticks = clock() - Begin;
- LOG("cCubicNoise generating 1000 * 256x256 values took %d ticks (%.02f sec)", Ticks, (double)Ticks / CLOCKS_PER_SEC);
-
- // Save the results into a file for visual comparison:
- SaveValues(Values, "NoiseCubic.raw");
-
- return Ticks;
-}
-
-
-
-
-
-clock_t TestOldNoise(void)
-{
- cNoise Noise(0);
- NOISE_DATATYPE Values[256 * 256];
-
- // Do a speed test:
- clock_t Begin = clock();
- for (int i = 0; i < 1000; i++)
- {
- for (int y = 0; y < 256; y++)
- {
- float fy = (float)y / 10;
- for (int x = 0; x < 256; x++)
- {
- Values[x + 256 * y] = Noise.CubicNoise2D((float)x / 10, fy);
- } // for x
- } // for y
- }
- clock_t Ticks = clock() - Begin;
- LOG("cNoise generating 1000 * 256x256 values took %d ticks (%.02f sec)", Ticks, (double)Ticks / CLOCKS_PER_SEC);
-
- // Save the results into a file for visual comparison:
- SaveValues(Values, "NoiseOld.raw");
-
- return Ticks;
-}
-
-
-
-
-
-int main(int argc, char * argv[])
-{
- new cMCLogger(); // Create a logger (will set itself as the main instance
-
- clock_t NewTicks = TestCubicNoise();
- clock_t OldTicks = TestOldNoise();
- LOG("New method is %.02fx faster", (double)OldTicks / NewTicks);
- LOG("Press Enter to quit program");
- getchar();
-}
+
+// NoiseTest.cpp
+
+// Implements the main app entrypoint
+
+#include "Globals.h"
+#include <time.h>
+#include "Noise.h"
+
+
+
+
+
+void SaveValues(NOISE_DATATYPE * a_Values, const AString & a_FileName)
+{
+ cFile f;
+ if (!f.Open(a_FileName, cFile::fmWrite))
+ {
+ LOGWARNING("Cannot write file %s", a_FileName.c_str());
+ return;
+ }
+ for (int y = 0; y < 256; y++)
+ {
+ unsigned char val[256];
+ for (int x = 0; x < 256; x++)
+ {
+ val[x] = std::min(255, std::max(0, (int)(256 * a_Values[x + 256 * y])));
+ }
+ f.Write(val, 256);
+ }
+}
+
+
+
+
+
+clock_t TestCubicNoise(void)
+{
+ cCubicNoise Cubic(0);
+ NOISE_DATATYPE Values[256 * 256];
+
+ // Do a speed test:
+ clock_t Begin = clock();
+ for (int i = 0; i < 1000; i++)
+ {
+ Cubic.Generate2D(Values, 256, 256, 0, (NOISE_DATATYPE)25.6, 0, (NOISE_DATATYPE)25.6);
+ }
+ clock_t Ticks = clock() - Begin;
+ LOG("cCubicNoise generating 1000 * 256x256 values took %d ticks (%.02f sec)", Ticks, (double)Ticks / CLOCKS_PER_SEC);
+
+ // Save the results into a file for visual comparison:
+ SaveValues(Values, "NoiseCubic.raw");
+
+ return Ticks;
+}
+
+
+
+
+
+clock_t TestOldNoise(void)
+{
+ cNoise Noise(0);
+ NOISE_DATATYPE Values[256 * 256];
+
+ // Do a speed test:
+ clock_t Begin = clock();
+ for (int i = 0; i < 1000; i++)
+ {
+ for (int y = 0; y < 256; y++)
+ {
+ float fy = (float)y / 10;
+ for (int x = 0; x < 256; x++)
+ {
+ Values[x + 256 * y] = Noise.CubicNoise2D((float)x / 10, fy);
+ } // for x
+ } // for y
+ }
+ clock_t Ticks = clock() - Begin;
+ LOG("cNoise generating 1000 * 256x256 values took %d ticks (%.02f sec)", Ticks, (double)Ticks / CLOCKS_PER_SEC);
+
+ // Save the results into a file for visual comparison:
+ SaveValues(Values, "NoiseOld.raw");
+
+ return Ticks;
+}
+
+
+
+
+
+int main(int argc, char * argv[])
+{
+ new cMCLogger(); // Create a logger (will set itself as the main instance
+
+ clock_t NewTicks = TestCubicNoise();
+ clock_t OldTicks = TestOldNoise();
+ LOG("New method is %.02fx faster", (double)OldTicks / NewTicks);
+ LOG("Press Enter to quit program");
+ getchar();
+}
diff --git a/Tests/NoiseTest/NoiseTest.sln b/Tests/NoiseTest/NoiseTest.sln
index bd55aeef1..240e97d01 100644
--- a/Tests/NoiseTest/NoiseTest.sln
+++ b/Tests/NoiseTest/NoiseTest.sln
@@ -1,20 +1,20 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NoiseTest", "NoiseTest.vcproj", "{8FDBCFC4-E1CF-4704-999C-29A08F9D6053}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Debug|Win32.ActiveCfg = Debug|Win32
- {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Debug|Win32.Build.0 = Debug|Win32
- {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Release|Win32.ActiveCfg = Release|Win32
- {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NoiseTest", "NoiseTest.vcproj", "{8FDBCFC4-E1CF-4704-999C-29A08F9D6053}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Debug|Win32.Build.0 = Debug|Win32
+ {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Release|Win32.ActiveCfg = Release|Win32
+ {8FDBCFC4-E1CF-4704-999C-29A08F9D6053}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Tests/NoiseTest/NoiseTest.vcproj b/Tests/NoiseTest/NoiseTest.vcproj
index a95740e82..d8741f74c 100644
--- a/Tests/NoiseTest/NoiseTest.vcproj
+++ b/Tests/NoiseTest/NoiseTest.vcproj
@@ -1,258 +1,258 @@
-<?xml version="1.0" encoding="windows-1250"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="NoiseTest"
- ProjectGUID="{8FDBCFC4-E1CF-4704-999C-29A08F9D6053}"
- RootNamespace="NoiseTest"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="../../source"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- FavorSizeOrSpeed="1"
- AdditionalIncludeDirectories="../../source"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\NoiseTest.cpp"
- >
- </File>
- <Filter
- Name="Shared"
- >
- <File
- RelativePath="..\..\source\Log.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\Log.h"
- >
- </File>
- <File
- RelativePath="..\..\source\MCLogger.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\MCLogger.h"
- >
- </File>
- <File
- RelativePath="..\..\source\Noise.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\Noise.h"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\StringUtils.h"
- >
- </File>
- <Filter
- Name="OSSupport"
- >
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\CriticalSection.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\File.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\File.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\IsThread.h"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\MakeDir.cpp"
- >
- </File>
- <File
- RelativePath="..\..\source\OSSupport\MakeDir.h"
- >
- </File>
- </Filter>
- </Filter>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="NoiseTest"
+ ProjectGUID="{8FDBCFC4-E1CF-4704-999C-29A08F9D6053}"
+ RootNamespace="NoiseTest"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../source"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ AdditionalIncludeDirectories="../../source"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.lib"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\NoiseTest.cpp"
+ >
+ </File>
+ <Filter
+ Name="Shared"
+ >
+ <File
+ RelativePath="..\..\source\Log.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Log.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\MCLogger.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\MCLogger.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Noise.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\Noise.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\StringUtils.h"
+ >
+ </File>
+ <Filter
+ Name="OSSupport"
+ >
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\CriticalSection.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\File.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\File.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\IsThread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\MakeDir.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\source\OSSupport\MakeDir.h"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>