summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp1
-rw-r--r--src/resources/mapreader.cpp9
-rw-r--r--src/utils/perfomance.cpp21
-rw-r--r--src/utils/perfomance.h4
4 files changed, 28 insertions, 7 deletions
diff --git a/src/client.cpp b/src/client.cpp
index e4fe1b4db..c1fbdae9d 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1575,6 +1575,7 @@ int Client::gameExec()
}
BLOCK_END("Client::gameExec 8")
}
+ PROFILER_END();
}
return 0;
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 9e6422c58..f8515d021 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -231,13 +231,13 @@ void MapReader::addLayerToList(const std::string &fileName)
Map *MapReader::readMap(const std::string &restrict filename,
const std::string &restrict realFilename)
{
- BLOCK_START("MapReader::readMap")
+ BLOCK_START("MapReader::readMap str")
logger->log("Attempting to read map %s", realFilename.c_str());
XML::Document doc(realFilename);
if (!doc.isLoaded())
{
- BLOCK_END("MapReader::readMap")
+ BLOCK_END("MapReader::readMap str")
return createEmptyMap(filename, realFilename);
}
@@ -267,7 +267,7 @@ Map *MapReader::readMap(const std::string &restrict filename,
updateMusic(map);
}
- BLOCK_END("MapReader::readMap")
+ BLOCK_END("MapReader::readMap str")
return map;
}
@@ -294,6 +294,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
if (!node)
return nullptr;
+ BLOCK_START("MapReader::readMap xml")
// Take the filename off the path
const std::string pathDir = path.substr(0, path.rfind("/") + 1);
@@ -311,6 +312,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
logger->log("MapReader: Warning: "
"Unitialized tile width or height value for map: %s",
path.c_str());
+ BLOCK_END("MapReader::readMap xml")
return nullptr;
}
@@ -451,6 +453,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
map->reduce();
map->setWalkLayer(resman->getWalkLayer(fileName, map));
unloadTempLayers();
+ BLOCK_END("MapReader::readMap xml")
return map;
}
diff --git a/src/utils/perfomance.cpp b/src/utils/perfomance.cpp
index 93d09cb40..d7ed52d4b 100644
--- a/src/utils/perfomance.cpp
+++ b/src/utils/perfomance.cpp
@@ -29,6 +29,7 @@
#include <algorithm>
#include <cstdarg>
#include <cstdio>
+#include <fcntl.h>
#include <fstream>
#include <iostream>
@@ -37,11 +38,12 @@
static const clockid_t clockType = CLOCK_MONOTONIC;
#define timeData ((static_cast<long long int>(time.tv_sec) * 1000000000LL \
- + static_cast<long long int>(time.tv_nsec)) / 1000)
+ + static_cast<long long int>(time.tv_nsec)) / 1)
namespace Perfomance
{
std::ofstream file;
+ std::string temp;
long long unsigned int startTime;
void init(const std::string &path)
@@ -49,6 +51,7 @@ namespace Perfomance
file.open(path.c_str(), std::ios_base::trunc);
timespec time;
clock_gettime(clockType, &time);
+ temp.reserve(10000000U);
startTime = timeData;
}
@@ -62,21 +65,31 @@ namespace Perfomance
{
timespec time;
clock_gettime(clockType, &time);
- file << (timeData - startTime) << " __init__" << std::endl;
+ temp.append(toString(timeData - startTime)).append(
+ " __init__\n");
}
void blockStart(const std::string &name)
{
timespec time;
clock_gettime(clockType, &time);
- file << (timeData - startTime) << " start: " << name << std::endl;
+ temp.append(toString(timeData - startTime)).append(
+ " start: ").append(name).append("\n");
}
void blockEnd(const std::string &name)
{
timespec time;
clock_gettime(clockType, &time);
- file << (timeData - startTime) << " end: " << name << std::endl;
+ temp.append(toString(timeData - startTime)).append(
+ " end: ").append(name).append("\n");
+ }
+
+ void flush()
+ {
+ file << temp;
+ temp.clear();
+// file.flush();
}
} // namespace Perfomance
diff --git a/src/utils/perfomance.h b/src/utils/perfomance.h
index c88859730..4a5f4fc17 100644
--- a/src/utils/perfomance.h
+++ b/src/utils/perfomance.h
@@ -31,6 +31,7 @@
#include "localconsts.h"
#define PROFILER_START() Perfomance::start();
+#define PROFILER_END() Perfomance::flush();
#define BLOCK_START(name) Perfomance::blockStart(name);
#define BLOCK_END(name) Perfomance::blockEnd(name);
#define FUNC_BLOCK(name, id) Perfomance::Func PerfomanceFunc##id(name);
@@ -47,6 +48,8 @@ namespace Perfomance
void blockEnd(const std::string &name);
+ void flush();
+
class Func final
{
public:
@@ -68,6 +71,7 @@ namespace Perfomance
#else // USE_PROFILER
#define PROFILER_START()
+#define PROFILER_END()
#define BLOCK_START(name)
#define BLOCK_END(name)
#define FUNC_BLOCK(name, id)