diff options
author | Darkvater <Darkvater@openttd.org> | 2007-01-12 16:30:41 +0000 |
---|---|---|
committer | Darkvater <Darkvater@openttd.org> | 2007-01-12 16:30:41 +0000 |
commit | a5cd65b3f961c190ee29ab76c896c7b06379af76 (patch) | |
tree | 7092bd6de5b70839f0e656d0cf42495ba63d9ed9 /src/yapf | |
parent | ae7d52e5aa603752736d69d208a3c0c9e862c96d (diff) | |
download | openttd-a5cd65b3f961c190ee29ab76c896c7b06379af76.tar.xz |
(svn r8080) -Codechange (r8079): Move the *WHOLE* performance code into the #ifndef and some style changes.
Diffstat (limited to 'src/yapf')
-rw-r--r-- | src/yapf/yapf_base.hpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/yapf/yapf_base.hpp b/src/yapf/yapf_base.hpp index 4382789cc..e474cb155 100644 --- a/src/yapf/yapf_base.hpp +++ b/src/yapf/yapf_base.hpp @@ -104,19 +104,21 @@ public: * - or the open list is empty (no route to destination). * - or the maximum amount of loops reached - m_max_search_nodes (default = 10000) * @return true if the path was found */ - inline bool FindPath(const Vehicle* v) + inline bool FindPath(const Vehicle *v) { m_veh = v; +#ifndef NO_DEBUG_MESSAGES CPerformanceTimer perf; perf.Start(); +#endif /* !NO_DEBUG_MESSAGES */ + Yapf().PfSetStartupNodes(); while (true) { m_num_steps++; - Node* n = m_nodes.GetBestOpenNode(); - if (n == NULL) - break; + Node *n = m_nodes.GetBestOpenNode(); + if (n == NULL) break; // if the best open node was worse than the best path found, we can finish if (m_pBestDestNode != NULL && m_pBestDestNode->GetCost() < n->GetCostEstimate()) @@ -131,24 +133,28 @@ public: break; } } - bool bDestFound = (m_pBestDestNode != NULL); - - int16 veh_idx = (m_veh != NULL) ? m_veh->unitnumber : 0; -// if (veh_idx != 433) return bDestFound; + bool bDestFound = (m_pBestDestNode != NULL); - perf.Stop(); - int t = perf.Get(1000000); - _total_pf_time_us += t; - char ttc = Yapf().TransportTypeChar(); #ifndef NO_DEBUG_MESSAGES + perf.Stop(); if (_debug_yapf_level >= 3) { + int t = perf.Get(1000000); + _total_pf_time_us += t; + + UnitID veh_idx = (m_veh != NULL) ? m_veh->unitnumber : 0; + char ttc = Yapf().TransportTypeChar(); 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 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; } |