Measure total time for NavMesh build from first pop

pull/1633/head
elsid 7 years ago
parent c26773bd29
commit f268ec5d34
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -105,6 +105,8 @@ namespace DetourNavigator
const auto start = std::chrono::steady_clock::now();
setFirstStart(start);
const auto recastMesh = getRecastMesh();
const auto status = updateNavMesh(job.mAgentHalfExtents, *recastMesh, job.mChangedTile, mSettings,
@ -117,7 +119,8 @@ namespace DetourNavigator
using FloatMs = std::chrono::duration<float, std::milli>;
log("cache updated for agent=", job.mAgentHalfExtents, " status=", status,
" time=", std::chrono::duration_cast<FloatMs>(finish - start).count(), "ms");
" time=", std::chrono::duration_cast<FloatMs>(finish - start).count(), "ms",
" total_time=", std::chrono::duration_cast<FloatMs>(finish - getFirstStart()).count(), "ms");
}
boost::optional<AsyncNavMeshUpdater::Job> AsyncNavMeshUpdater::getNextJob()
@ -168,4 +171,17 @@ namespace DetourNavigator
const std::lock_guard<std::mutex> lock(mRecastMeshMutex);
mRecastMesh = value;
}
std::chrono::steady_clock::time_point AsyncNavMeshUpdater::getFirstStart()
{
const std::lock_guard<std::mutex> lock(mFirstStartMutex);
return *mFirstStart;
}
void AsyncNavMeshUpdater::setFirstStart(const std::chrono::steady_clock::time_point& value)
{
const std::lock_guard<std::mutex> lock(mFirstStartMutex);
if (!mFirstStart)
mFirstStart = value;
}
}

@ -10,8 +10,8 @@
#include <boost/optional.hpp>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <map>
#include <memory>
#include <mutex>
#include <queue>
@ -58,6 +58,8 @@ namespace DetourNavigator
Jobs mJobs;
std::mutex mRecastMeshMutex;
std::shared_ptr<RecastMesh> mRecastMesh;
std::mutex mFirstStartMutex;
boost::optional<std::chrono::steady_clock::time_point> mFirstStart;
std::thread mThread;
void process() throw();
@ -73,6 +75,10 @@ namespace DetourNavigator
std::shared_ptr<RecastMesh> getRecastMesh();
void setRecastMesh(const std::shared_ptr<RecastMesh>& value);
std::chrono::steady_clock::time_point getFirstStart();
void setFirstStart(const std::chrono::steady_clock::time_point& value);
};
}

Loading…
Cancel
Save