diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/ChunkStorageProfileDecorator.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.World/ChunkStorageProfileDecorator.cpp')
| -rw-r--r-- | Minecraft.World/ChunkStorageProfileDecorator.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Minecraft.World/ChunkStorageProfileDecorator.cpp b/Minecraft.World/ChunkStorageProfileDecorator.cpp new file mode 100644 index 00000000..76ffddbc --- /dev/null +++ b/Minecraft.World/ChunkStorageProfileDecorator.cpp @@ -0,0 +1,71 @@ +#include "stdafx.h" +#include "System.h" +#include "ChunkStorageProfileDecorator.h" + +ChunkStorageProfilerDecorator::ChunkStorageProfilerDecorator(ChunkStorage *capsulated) : + timeSpentLoading(0), loadCount(0), timeSpentSaving(0), saveCount(0), counter(0) +{ + this->capsulated = capsulated; +} + +LevelChunk *ChunkStorageProfilerDecorator::load(Level *level, int x, int z) +{ + __int64 nanoTime = System::nanoTime(); + LevelChunk *chunk = capsulated->load(level, x, z); + timeSpentLoading += System::nanoTime() - nanoTime; + loadCount++; + + return chunk; +} + +void ChunkStorageProfilerDecorator::save(Level *level, LevelChunk *levelChunk) +{ + __int64 nanoTime = System::nanoTime(); + capsulated->save(level, levelChunk); + timeSpentSaving += System::nanoTime() - nanoTime; + saveCount++; +} + +void ChunkStorageProfilerDecorator::saveEntities(Level *level, LevelChunk *levelChunk) +{ + capsulated->saveEntities(level, levelChunk); +} + +void ChunkStorageProfilerDecorator::tick() +{ + char buf[256]; + capsulated->tick(); + + counter++; + if (counter > 500) + { + if (loadCount > 0) + { +#ifndef _CONTENT_PACKAGE +#ifdef __PSVITA__ + sprintf(buf,"Average load time: %f (%lld)",0.000001 * (double) timeSpentLoading / (double) loadCount, loadCount); +#else + sprintf(buf,"Average load time: %f (%I64d)",0.000001 * (double) timeSpentLoading / (double) loadCount, loadCount); +#endif + app.DebugPrintf(buf); +#endif + } + if (saveCount > 0) + { +#ifndef _CONTENT_PACKAGE +#ifdef __PSVITA__ + sprintf(buf,"Average save time: %f (%lld)",0.000001 * (double) timeSpentSaving / (double) loadCount, loadCount); +#else + sprintf(buf,"Average save time: %f (%I64d)",0.000001 * (double) timeSpentSaving / (double) loadCount, loadCount); +#endif + app.DebugPrintf(buf); +#endif + } + counter = 0; + } +} + +void ChunkStorageProfilerDecorator::flush() +{ + capsulated->flush(); +}
\ No newline at end of file |
