diff options
author | Mattes D <github@xoft.cz> | 2014-11-03 10:36:12 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-11-03 10:36:12 +0100 |
commit | f5c4a6a27d7c35afbbb57e0798d1473e2795ca22 (patch) | |
tree | a30c57a24e89d3e612d22ddb8aaa9e38de18e238 /src/Generating/BioGen.cpp | |
parent | HeiGen: Moved construction to the end of file. (diff) | |
download | cuberite-f5c4a6a27d7c35afbbb57e0798d1473e2795ca22.tar cuberite-f5c4a6a27d7c35afbbb57e0798d1473e2795ca22.tar.gz cuberite-f5c4a6a27d7c35afbbb57e0798d1473e2795ca22.tar.bz2 cuberite-f5c4a6a27d7c35afbbb57e0798d1473e2795ca22.tar.lz cuberite-f5c4a6a27d7c35afbbb57e0798d1473e2795ca22.tar.xz cuberite-f5c4a6a27d7c35afbbb57e0798d1473e2795ca22.tar.zst cuberite-f5c4a6a27d7c35afbbb57e0798d1473e2795ca22.zip |
Diffstat (limited to 'src/Generating/BioGen.cpp')
-rw-r--r-- | src/Generating/BioGen.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp index 0f2b0a73d..5480d8d4c 100644 --- a/src/Generating/BioGen.cpp +++ b/src/Generating/BioGen.cpp @@ -5,6 +5,8 @@ #include "Globals.h" #include "BioGen.h" +#include <chrono> +#include <iostream> #include "IntGen.h" #include "ProtIntGen.h" #include "../IniFile.h" @@ -1199,3 +1201,47 @@ cBiomeGenPtr cBiomeGen::CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & + +//////////////////////////////////////////////////////////////////////////////// +// Performance tests: + +// Change to 1 to enable the perf test: +#if 0 + +class cBioGenPerfTest +{ +public: + cBioGenPerfTest() + { + std::cout << "BioGen performance tests commencing, please wait..." << std::endl; + TestGen("MultiStepMap", std::make_unique<cBioGenMultiStepMap>(1).get()); + TestGen("Grown", std::make_unique<cBioGenGrown>(1).get()); + TestGen("GrownProt", std::make_unique<cBioGenProtGrown>(1).get()); + std::cout << "BioGen performance tests complete." << std::endl; + } + +protected: + void TestGen(const AString && a_GenName, cBiomeGen * a_BioGen) + { + // Initialize the default settings for the generator: + cIniFile iniFile; + a_BioGen->InitializeBiomeGen(iniFile); + + // Generate the biomes: + auto start = std::chrono::system_clock::now(); + for (int z = 0; z < 100; z++) + { + for (int x = 0; x < 100; x++) + { + cChunkDef::BiomeMap biomes; + a_BioGen->GenBiomes(x, z, biomes); + } // for x + } // for z + auto dur = std::chrono::system_clock::now() - start; + double milliseconds = static_cast<double>((std::chrono::duration_cast<std::chrono::milliseconds>(dur)).count()); + + std::cout << a_GenName << ": " << 1000.0 * 100.0 * 100.0 / milliseconds << " chunks per second" << std::endl; + } +} g_BioGenPerfTest; + +#endif
\ No newline at end of file |