Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/tests/test_Serializer.h
Show All 22 Lines | |||||
#include "simulation2/serialization/StdDeserializer.h" | #include "simulation2/serialization/StdDeserializer.h" | ||||
#include "scriptinterface/FunctionWrapper.h" | #include "scriptinterface/FunctionWrapper.h" | ||||
#include "scriptinterface/ScriptContext.h" | #include "scriptinterface/ScriptContext.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include "graphics/MapReader.h" | #include "graphics/MapReader.h" | ||||
#include "graphics/Terrain.h" | #include "graphics/Terrain.h" | ||||
#include "graphics/TerrainTextureManager.h" | #include "graphics/TerrainTextureManager.h" | ||||
#include "lib/config2.h" | |||||
#include "lib/timer.h" | #include "lib/timer.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/Loader.h" | #include "ps/Loader.h" | ||||
#include "ps/XML/Xeromyces.h" | #include "ps/XML/Xeromyces.h" | ||||
#include "simulation2/Simulation2.h" | #include "simulation2/Simulation2.h" | ||||
#if CONFIG2_VALGRIND | |||||
#include "callgrind.h" | # include "callgrind.h" | ||||
#endif | |||||
#include <iostream> | #include <iostream> | ||||
#define TS_ASSERT_STREAM(stream, len, buffer) \ | #define TS_ASSERT_STREAM(stream, len, buffer) \ | ||||
TS_ASSERT_EQUALS(stream.str().length(), (size_t)len); \ | TS_ASSERT_EQUALS(stream.str().length(), (size_t)len); \ | ||||
TS_ASSERT_SAME_DATA(stream.str().data(), buffer, len) | TS_ASSERT_SAME_DATA(stream.str().data(), buffer, len) | ||||
#define TSM_ASSERT_STREAM(m, stream, len, buffer) \ | #define TSM_ASSERT_STREAM(m, stream, len, buffer) \ | ||||
TSM_ASSERT_EQUALS(m, stream.str().length(), (size_t)len); \ | TSM_ASSERT_EQUALS(m, stream.str().length(), (size_t)len); \ | ||||
▲ Show 20 Lines • Show All 867 Lines • ▼ Show 20 Lines | sim2.Update(0); | ||||
debug_printf("# size = %d\n", (int)str.str().length()); | debug_printf("# size = %d\n", (int)str.str().length()); | ||||
debug_printf("# hash = "); | debug_printf("# hash = "); | ||||
for (size_t i = 0; i < hash.size(); ++i) | for (size_t i = 0; i < hash.size(); ++i) | ||||
debug_printf("%02x", (unsigned int)(u8)hash[i]); | debug_printf("%02x", (unsigned int)(u8)hash[i]); | ||||
debug_printf("\n"); | debug_printf("\n"); | ||||
} | } | ||||
double t = timer_Time(); | double t = timer_Time(); | ||||
#if CONFIG2_VALGRIND | |||||
CALLGRIND_START_INSTRUMENTATION; | CALLGRIND_START_INSTRUMENTATION; | ||||
#endif | |||||
size_t reps = 128; | size_t reps = 128; | ||||
for (size_t i = 0; i < reps; ++i) | for (size_t i = 0; i < reps; ++i) | ||||
{ | { | ||||
std::string hash; | std::string hash; | ||||
sim2.ComputeStateHash(hash, false); | sim2.ComputeStateHash(hash, false); | ||||
} | } | ||||
#if CONFIG2_VALGRIND | |||||
CALLGRIND_STOP_INSTRUMENTATION; | CALLGRIND_STOP_INSTRUMENTATION; | ||||
#endif | |||||
t = timer_Time() - t; | t = timer_Time() - t; | ||||
debug_printf("# time = %f (%f/%d)\n", t/reps, t, (int)reps); | debug_printf("# time = %f (%f/%d)\n", t/reps, t, (int)reps); | ||||
// Shut down the world | // Shut down the world | ||||
delete &g_TexMan; | delete &g_TexMan; | ||||
g_VFS.reset(); | g_VFS.reset(); | ||||
DeleteDirectory(DataDir()/"_testcache"); | DeleteDirectory(DataDir()/"_testcache"); | ||||
CXeromyces::Terminate(); | CXeromyces::Terminate(); | ||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator