mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
(svn r8080) -Codechange (r8079): Move the *WHOLE* performance code into the #ifndef and some style changes.
This commit is contained in:
parent
ae7d52e5aa
commit
a5cd65b3f9
@ -104,19 +104,21 @@ public:
|
|||||||
* - or the open list is empty (no route to destination).
|
* - or the open list is empty (no route to destination).
|
||||||
* - or the maximum amount of loops reached - m_max_search_nodes (default = 10000)
|
* - or the maximum amount of loops reached - m_max_search_nodes (default = 10000)
|
||||||
* @return true if the path was found */
|
* @return true if the path was found */
|
||||||
inline bool FindPath(const Vehicle* v)
|
inline bool FindPath(const Vehicle *v)
|
||||||
{
|
{
|
||||||
m_veh = v;
|
m_veh = v;
|
||||||
|
|
||||||
|
#ifndef NO_DEBUG_MESSAGES
|
||||||
CPerformanceTimer perf;
|
CPerformanceTimer perf;
|
||||||
perf.Start();
|
perf.Start();
|
||||||
|
#endif /* !NO_DEBUG_MESSAGES */
|
||||||
|
|
||||||
Yapf().PfSetStartupNodes();
|
Yapf().PfSetStartupNodes();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
m_num_steps++;
|
m_num_steps++;
|
||||||
Node* n = m_nodes.GetBestOpenNode();
|
Node *n = m_nodes.GetBestOpenNode();
|
||||||
if (n == NULL)
|
if (n == NULL) break;
|
||||||
break;
|
|
||||||
|
|
||||||
// if the best open node was worse than the best path found, we can finish
|
// if the best open node was worse than the best path found, we can finish
|
||||||
if (m_pBestDestNode != NULL && m_pBestDestNode->GetCost() < n->GetCostEstimate())
|
if (m_pBestDestNode != NULL && m_pBestDestNode->GetCost() < n->GetCostEstimate())
|
||||||
@ -131,24 +133,28 @@ public:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bDestFound = (m_pBestDestNode != NULL);
|
bool bDestFound = (m_pBestDestNode != NULL);
|
||||||
|
|
||||||
int16 veh_idx = (m_veh != NULL) ? m_veh->unitnumber : 0;
|
#ifndef NO_DEBUG_MESSAGES
|
||||||
|
|
||||||
// if (veh_idx != 433) return bDestFound;
|
|
||||||
|
|
||||||
perf.Stop();
|
perf.Stop();
|
||||||
|
if (_debug_yapf_level >= 3) {
|
||||||
int t = perf.Get(1000000);
|
int t = perf.Get(1000000);
|
||||||
_total_pf_time_us += t;
|
_total_pf_time_us += t;
|
||||||
|
|
||||||
|
UnitID veh_idx = (m_veh != NULL) ? m_veh->unitnumber : 0;
|
||||||
char ttc = Yapf().TransportTypeChar();
|
char ttc = Yapf().TransportTypeChar();
|
||||||
#ifndef NO_DEBUG_MESSAGES
|
|
||||||
if (_debug_yapf_level >= 3) {
|
|
||||||
float cache_hit_ratio = (m_stats_cache_hits == 0) ? 0.0f : ((float)m_stats_cache_hits / (float)(m_stats_cache_hits + m_stats_cost_calcs) * 100.0f);
|
float cache_hit_ratio = (m_stats_cache_hits == 0) ? 0.0f : ((float)m_stats_cache_hits / (float)(m_stats_cache_hits + m_stats_cost_calcs) * 100.0f);
|
||||||
int cost = bDestFound ? m_pBestDestNode->m_cost : -1;
|
int cost = bDestFound ? m_pBestDestNode->m_cost : -1;
|
||||||
int dist = bDestFound ? m_pBestDestNode->m_estimate - m_pBestDestNode->m_cost : -1;
|
int dist = bDestFound ? m_pBestDestNode->m_estimate - m_pBestDestNode->m_cost : -1;
|
||||||
DEBUG(yapf, 3, "[YAPF%c]%c%4d- %d us - %d rounds - %d open - %d closed - CHR %4.1f%% - c%d(sc%d, ts%d, o%d) -- ", ttc, bDestFound ? '-' : '!', veh_idx, t, m_num_steps, m_nodes.OpenCount(), m_nodes.ClosedCount(), cache_hit_ratio, cost, dist, m_perf_cost.Get(1000000), m_perf_slope_cost.Get(1000000), m_perf_ts_cost.Get(1000000), m_perf_other_cost.Get(1000000));
|
|
||||||
|
DEBUG(yapf, 3, "[YAPF%c]%c%4d- %d us - %d rounds - %d open - %d closed - CHR %4.1f%% - c%d(sc%d, ts%d, o%d) -- ",
|
||||||
|
ttc, bDestFound ? '-' : '!', veh_idx, t, m_num_steps, m_nodes.OpenCount(), m_nodes.ClosedCount(),
|
||||||
|
cache_hit_ratio, cost, dist, m_perf_cost.Get(1000000), m_perf_slope_cost.Get(1000000),
|
||||||
|
m_perf_ts_cost.Get(1000000), m_perf_other_cost.Get(1000000)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
#endif //!NO_DEBUG_MESSAGES
|
#endif /* !NO_DEBUG_MESSAGES */
|
||||||
return bDestFound;
|
return bDestFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user