the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "System.h"
3#include "ChunkStorageProfileDecorator.h"
4
5ChunkStorageProfilerDecorator::ChunkStorageProfilerDecorator(ChunkStorage *capsulated) :
6 timeSpentLoading(0), loadCount(0), timeSpentSaving(0), saveCount(0), counter(0)
7{
8 this->capsulated = capsulated;
9}
10
11LevelChunk *ChunkStorageProfilerDecorator::load(Level *level, int x, int z)
12{
13 __int64 nanoTime = System::nanoTime();
14 LevelChunk *chunk = capsulated->load(level, x, z);
15 timeSpentLoading += System::nanoTime() - nanoTime;
16 loadCount++;
17
18 return chunk;
19}
20
21void ChunkStorageProfilerDecorator::save(Level *level, LevelChunk *levelChunk)
22{
23 __int64 nanoTime = System::nanoTime();
24 capsulated->save(level, levelChunk);
25 timeSpentSaving += System::nanoTime() - nanoTime;
26 saveCount++;
27}
28
29void ChunkStorageProfilerDecorator::saveEntities(Level *level, LevelChunk *levelChunk)
30{
31 capsulated->saveEntities(level, levelChunk);
32}
33
34void ChunkStorageProfilerDecorator::tick()
35{
36 char buf[256];
37 capsulated->tick();
38
39 counter++;
40 if (counter > 500)
41 {
42 if (loadCount > 0)
43 {
44#ifndef _CONTENT_PACKAGE
45#ifdef __PSVITA__
46 sprintf(buf,"Average load time: %f (%lld)",0.000001 * (double) timeSpentLoading / (double) loadCount, loadCount);
47#else
48 sprintf(buf,"Average load time: %f (%I64d)",0.000001 * (double) timeSpentLoading / (double) loadCount, loadCount);
49#endif
50 app.DebugPrintf(buf);
51#endif
52 }
53 if (saveCount > 0)
54 {
55#ifndef _CONTENT_PACKAGE
56#ifdef __PSVITA__
57 sprintf(buf,"Average save time: %f (%lld)",0.000001 * (double) timeSpentSaving / (double) loadCount, loadCount);
58#else
59 sprintf(buf,"Average save time: %f (%I64d)",0.000001 * (double) timeSpentSaving / (double) loadCount, loadCount);
60#endif
61 app.DebugPrintf(buf);
62#endif
63 }
64 counter = 0;
65 }
66}
67
68void ChunkStorageProfilerDecorator::flush()
69{
70 capsulated->flush();
71}