Change profiling calls to get a better view of what is actually slow and what is not.
This was SVN commit r18438.
This commit is contained in:
parent
d2e081b602
commit
898ab5229b
@ -268,6 +268,32 @@ bool ProfileStop(JSContext* UNUSED(cx), uint UNUSED(argc), jsval* vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProfileAttribute(JSContext* cx, uint argc, jsval* vp)
|
||||
{
|
||||
const char* name = "(ProfileAttribute)";
|
||||
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
if (args.length() >= 1)
|
||||
{
|
||||
std::string str;
|
||||
if (!ScriptInterface::FromJSVal(cx, args[0], str))
|
||||
return false;
|
||||
|
||||
typedef boost::flyweight<
|
||||
std::string,
|
||||
boost::flyweights::no_tracking,
|
||||
boost::flyweights::no_locking
|
||||
> StringFlyweight;
|
||||
|
||||
name = StringFlyweight(str).get().c_str();
|
||||
}
|
||||
|
||||
g_Profiler2.RecordAttribute(name);
|
||||
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Math override functions:
|
||||
|
||||
// boost::uniform_real is apparently buggy in Boost pre-1.47 - for integer generators
|
||||
@ -364,6 +390,7 @@ ScriptInterface_impl::ScriptInterface_impl(const char* nativeScopeName, const sh
|
||||
|
||||
Register("ProfileStart", ::ProfileStart, 1);
|
||||
Register("ProfileStop", ::ProfileStop, 0);
|
||||
Register("ProfileAttribute", ::ProfileAttribute, 1);
|
||||
|
||||
runtime->RegisterContext(m_cx);
|
||||
}
|
||||
|
@ -480,8 +480,11 @@ void CSimulation2Impl::UpdateComponents(CSimContext& simContext, fixed turnLengt
|
||||
|
||||
CComponentManager& componentManager = simContext.GetComponentManager();
|
||||
|
||||
{
|
||||
PROFILE2("Sim - Update Start");
|
||||
CMessageTurnStart msgTurnStart;
|
||||
componentManager.BroadcastMessage(msgTurnStart);
|
||||
}
|
||||
|
||||
CmpPtr<ICmpPathfinder> cmpPathfinder(simContext, SYSTEM_ENTITY);
|
||||
if (cmpPathfinder)
|
||||
@ -505,6 +508,7 @@ void CSimulation2Impl::UpdateComponents(CSimContext& simContext, fixed turnLengt
|
||||
|
||||
// Send all the update phases
|
||||
{
|
||||
PROFILE2("Sim - Update");
|
||||
CMessageUpdate msgUpdate(turnLengthFixed);
|
||||
componentManager.BroadcastMessage(msgUpdate);
|
||||
}
|
||||
@ -518,10 +522,12 @@ void CSimulation2Impl::UpdateComponents(CSimContext& simContext, fixed turnLengt
|
||||
cmpPathfinder->ProcessSameTurnMoves();
|
||||
|
||||
{
|
||||
PROFILE2("Sim - Motion Unit");
|
||||
CMessageUpdate_MotionUnit msgUpdate(turnLengthFixed);
|
||||
componentManager.BroadcastMessage(msgUpdate);
|
||||
}
|
||||
{
|
||||
PROFILE2("Sim - Update Final");
|
||||
CMessageUpdate_Final msgUpdate(turnLengthFixed);
|
||||
componentManager.BroadcastMessage(msgUpdate);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public:
|
||||
{
|
||||
case MT_Interpolate:
|
||||
{
|
||||
PROFILE3("Decay::Interpolate");
|
||||
PROFILE("Decay::Interpolate");
|
||||
|
||||
if (!m_Active)
|
||||
break;
|
||||
|
@ -839,7 +839,7 @@ bool CCmpObstructionManager::TestUnitShape(const IObstructionTestFilter& filter,
|
||||
|
||||
void CCmpObstructionManager::Rasterize(Grid<NavcellData>& grid, const std::vector<PathfinderPassability>& passClasses, bool fullUpdate)
|
||||
{
|
||||
PROFILE3("Rasterize");
|
||||
PROFILE3("Rasterize Obstructions");
|
||||
|
||||
// Cells are only marked as blocked if the whole cell is strictly inside the shape.
|
||||
// (That ensures the shape's geometric border is always reachable.)
|
||||
|
@ -80,14 +80,14 @@ public:
|
||||
{
|
||||
case MT_Interpolate:
|
||||
{
|
||||
PROFILE3("OverlayRenderer::Interpolate");
|
||||
PROFILE("OverlayRenderer::Interpolate");
|
||||
const CMessageInterpolate& msgData = static_cast<const CMessageInterpolate&> (msg);
|
||||
Interpolate(msgData.deltaSimTime, msgData.offset);
|
||||
break;
|
||||
}
|
||||
case MT_RenderSubmit:
|
||||
{
|
||||
PROFILE3("OverlayRenderer::RenderSubmit");
|
||||
PROFILE("OverlayRenderer::RenderSubmit");
|
||||
const CMessageRenderSubmit& msgData = static_cast<const CMessageRenderSubmit&> (msg);
|
||||
RenderSubmit(msgData.collector);
|
||||
break;
|
||||
|
@ -684,6 +684,7 @@ u32 CCmpPathfinder::ComputeShortPathAsync(entity_pos_t x0, entity_pos_t z0, enti
|
||||
|
||||
void CCmpPathfinder::FinishAsyncRequests()
|
||||
{
|
||||
PROFILE2("Finish Async Requests");
|
||||
// Save the request queue in case it gets modified while iterating
|
||||
std::vector<AsyncLongPathRequest> longRequests;
|
||||
m_AsyncLongPathRequests.swap(longRequests);
|
||||
@ -702,6 +703,7 @@ void CCmpPathfinder::FinishAsyncRequests()
|
||||
|
||||
void CCmpPathfinder::ProcessLongRequests(const std::vector<AsyncLongPathRequest>& longRequests)
|
||||
{
|
||||
PROFILE2("Process Long Requests");
|
||||
for (size_t i = 0; i < longRequests.size(); ++i)
|
||||
{
|
||||
const AsyncLongPathRequest& req = longRequests[i];
|
||||
@ -714,6 +716,7 @@ void CCmpPathfinder::ProcessLongRequests(const std::vector<AsyncLongPathRequest>
|
||||
|
||||
void CCmpPathfinder::ProcessShortRequests(const std::vector<AsyncShortPathRequest>& shortRequests)
|
||||
{
|
||||
PROFILE2("Process Short Requests");
|
||||
for (size_t i = 0; i < shortRequests.size(); ++i)
|
||||
{
|
||||
const AsyncShortPathRequest& req = shortRequests[i];
|
||||
@ -788,6 +791,8 @@ bool CCmpPathfinder::CheckMovement(const IObstructionTestFilter& filter,
|
||||
entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r,
|
||||
pass_class_t passClass)
|
||||
{
|
||||
PROFILE2_IFSPIKE("Check Movement", 0.001);
|
||||
|
||||
// Test against obstructions first. filter may discard pathfinding-blocking obstructions.
|
||||
// Use more permissive version of TestLine to allow unit-unit collisions to overlap slightly.
|
||||
// This makes movement smoother and more natural for units, overall.
|
||||
|
@ -513,8 +513,7 @@ void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter,
|
||||
entity_pos_t x0, entity_pos_t z0, entity_pos_t clearance,
|
||||
entity_pos_t range, const PathGoal& goal, pass_class_t passClass, WaypointPath& path)
|
||||
{
|
||||
PROFILE3("ComputeShortPath");
|
||||
|
||||
PROFILE("ComputeShortPath");
|
||||
m_DebugOverlayShortPathLines.clear();
|
||||
|
||||
if (m_DebugOverlay)
|
||||
|
@ -759,7 +759,7 @@ public:
|
||||
{
|
||||
case MT_Interpolate:
|
||||
{
|
||||
PROFILE3("Position::Interpolate");
|
||||
PROFILE("Position::Interpolate");
|
||||
|
||||
const CMessageInterpolate& msgData = static_cast<const CMessageInterpolate&> (msg);
|
||||
|
||||
|
@ -218,7 +218,7 @@ public:
|
||||
{
|
||||
case MT_RenderSubmit:
|
||||
{
|
||||
PROFILE3("RallyPoint::RenderSubmit");
|
||||
PROFILE("RallyPoint::RenderSubmit");
|
||||
if (m_Displayed && IsSet())
|
||||
{
|
||||
const CMessageRenderSubmit& msgData = static_cast<const CMessageRenderSubmit&> (msg);
|
||||
|
@ -289,7 +289,7 @@ void CCmpSelectable::HandleMessage(const CMessage& msg, bool UNUSED(global))
|
||||
{
|
||||
case MT_Interpolate:
|
||||
{
|
||||
PROFILE3("Selectable::Interpolate");
|
||||
PROFILE("Selectable::Interpolate");
|
||||
|
||||
const CMessageInterpolate& msgData = static_cast<const CMessageInterpolate&> (msg);
|
||||
|
||||
@ -363,7 +363,7 @@ void CCmpSelectable::HandleMessage(const CMessage& msg, bool UNUSED(global))
|
||||
break;
|
||||
case MT_RenderSubmit:
|
||||
{
|
||||
PROFILE3("Selectable::RenderSubmit");
|
||||
PROFILE("Selectable::RenderSubmit");
|
||||
|
||||
const CMessageRenderSubmit& msgData = static_cast<const CMessageRenderSubmit&> (msg);
|
||||
RenderSubmit(msgData.collector);
|
||||
|
@ -395,7 +395,7 @@ public:
|
||||
}
|
||||
case MT_RenderSubmit:
|
||||
{
|
||||
PROFILE3("UnitMotion::RenderSubmit");
|
||||
PROFILE("UnitMotion::RenderSubmit");
|
||||
const CMessageRenderSubmit& msgData = static_cast<const CMessageRenderSubmit&> (msg);
|
||||
RenderSubmit(msgData.collector);
|
||||
break;
|
||||
|
@ -573,6 +573,7 @@ HierarchicalPathfinder::RegionID HierarchicalPathfinder::Get(u16 i, u16 j, pass_
|
||||
|
||||
void HierarchicalPathfinder::MakeGoalReachable(u16 i0, u16 j0, PathGoal& goal, pass_class_t passClass)
|
||||
{
|
||||
PROFILE2("MakeGoalReachable");
|
||||
RegionID source = Get(i0, j0, passClass);
|
||||
|
||||
// Find everywhere that's reachable
|
||||
|
@ -784,8 +784,8 @@ void LongPathfinder::AddJumpedDiag(int i, int j, int di, int dj, PathCost g, Pat
|
||||
|
||||
void LongPathfinder::ComputeJPSPath(entity_pos_t x0, entity_pos_t z0, const PathGoal& origGoal, pass_class_t passClass, WaypointPath& path)
|
||||
{
|
||||
PROFILE3("ComputePathJPS");
|
||||
|
||||
PROFILE("ComputePathJPS");
|
||||
PROFILE2_IFSPIKE("ComputePathJPS", 0.0002);
|
||||
PathfinderState state = { 0 };
|
||||
|
||||
state.jpc = m_JumpPointCache[passClass].get();
|
||||
|
@ -898,6 +898,7 @@ void CComponentManager::DestroyComponentsSoon(entity_id_t ent)
|
||||
|
||||
void CComponentManager::FlushDestroyedComponents()
|
||||
{
|
||||
PROFILE2("Flush Destroyed Components");
|
||||
while (!m_DestructionQueue.empty())
|
||||
{
|
||||
// Make a copy of the destruction queue, so that the iterators won't be invalidated if the
|
||||
@ -998,6 +999,8 @@ const CComponentManager::InterfaceListUnordered& CComponentManager::GetEntitiesW
|
||||
|
||||
void CComponentManager::PostMessage(entity_id_t ent, const CMessage& msg)
|
||||
{
|
||||
PROFILE2_IFSPIKE("Post Message", 0.0005);
|
||||
PROFILE2_ATTR("%s", msg.GetScriptHandlerName());
|
||||
// Send the message to components of ent, that subscribed locally to this message
|
||||
std::map<MessageTypeId, std::vector<ComponentTypeId> >::const_iterator it;
|
||||
it = m_LocalMessageSubscriptions.find(msg.GetType());
|
||||
@ -1048,6 +1051,8 @@ void CComponentManager::BroadcastMessage(const CMessage& msg)
|
||||
|
||||
void CComponentManager::SendGlobalMessage(entity_id_t ent, const CMessage& msg)
|
||||
{
|
||||
PROFILE2_IFSPIKE("SendGlobalMessage", 0.001);
|
||||
PROFILE2_ATTR("%s", msg.GetScriptHandlerName());
|
||||
// (Common functionality for PostMessage and BroadcastMessage)
|
||||
|
||||
// Send the message to components of all entities that subscribed globally to this message
|
||||
|
Loading…
Reference in New Issue
Block a user