Move NL_KEEP_STATISTICS from netlist_types to the individual use cases.

(nw)
This commit is contained in:
couriersud 2019-01-11 08:03:27 +01:00
parent 414d43cc16
commit 7ababd6091
4 changed files with 26 additions and 28 deletions

View File

@ -22,13 +22,11 @@ namespace netlist
// Performance tracking
//============================================================
#if NL_KEEP_STATISTICS
using nperftime_t = plib::chrono::timer<plib::chrono::exact_ticks, true>;
using nperfcount_t = plib::chrono::counter<true>;
#else
using nperftime_t = plib::chrono::timer<plib::chrono::exact_ticks, false>;
using nperfcount_t = plib::chrono::counter<false>;
#endif
template<bool enabled_>
using nperftime_t = plib::chrono::timer<plib::chrono::exact_ticks, enabled_>;
template<bool enabled_>
using nperfcount_t = plib::chrono::counter<enabled_>;
//============================================================
// Types needed by various includes

View File

@ -147,7 +147,7 @@ const logic_family_desc_t *family_CD4XXX()
// ----------------------------------------------------------------------------------------
detail::queue_t::queue_t(netlist_t &nl)
: timed_queue<pqentry_t<net_t *, netlist_time>, false>(512)
: timed_queue<pqentry_t<net_t *, netlist_time>, false, NL_KEEP_STATISTICS>(512)
, netlist_ref(nl)
, plib::state_manager_t::callback_t()
, m_qsize(0)
@ -585,7 +585,7 @@ void netlist_t::process_queue(const netlist_time &delta) NL_NOEXCEPT
void netlist_t::print_stats() const
{
if (nperftime_t::enabled)
if (nperftime_t<NL_KEEP_STATISTICS>::enabled)
{
std::vector<size_t> index;
for (size_t i=0; i<m_devices.size(); i++)
@ -594,7 +594,7 @@ void netlist_t::print_stats() const
std::sort(index.begin(), index.end(),
[&](size_t i1, size_t i2) { return m_devices[i1]->m_stat_total_time.total() < m_devices[i2]->m_stat_total_time.total(); });
nperftime_t::type total_time(0);
nperftime_t<NL_KEEP_STATISTICS>::type total_time(0);
uint_least64_t total_count(0);
for (auto & j : index)
@ -607,8 +607,8 @@ void netlist_t::print_stats() const
total_count += entry->m_stat_total_time.count();
}
nperftime_t overhead;
nperftime_t test;
nperftime_t<NL_KEEP_STATISTICS> overhead;
nperftime_t<NL_KEEP_STATISTICS> test;
overhead.start();
for (int j=0; j<100000;j++)
{
@ -617,9 +617,9 @@ void netlist_t::print_stats() const
}
overhead.stop();
nperftime_t::type total_overhead = overhead()
* static_cast<nperftime_t::type>(total_count)
/ static_cast<nperftime_t::type>(200000);
nperftime_t<NL_KEEP_STATISTICS>::type total_overhead = overhead()
* static_cast<nperftime_t<NL_KEEP_STATISTICS>::type>(total_count)
/ static_cast<nperftime_t<NL_KEEP_STATISTICS>::type>(200000);
log().verbose("Queue Pushes {1:15}", queue().m_prof_call());
log().verbose("Queue Moves {1:15}", queue().m_prof_sortmove());
@ -631,8 +631,8 @@ void netlist_t::print_stats() const
log().verbose("");
log().verbose("Take the next lines with a grain of salt. They depend on the measurement implementation.");
log().verbose("Total overhead {1:15}", total_overhead);
nperftime_t::type overhead_per_pop = (m_stat_mainloop()-2*total_overhead - (total_time - total_overhead))
/ static_cast<nperftime_t::type>(queue().m_prof_call());
nperftime_t<NL_KEEP_STATISTICS>::type overhead_per_pop = (m_stat_mainloop()-2*total_overhead - (total_time - total_overhead))
/ static_cast<nperftime_t<NL_KEEP_STATISTICS>::type>(queue().m_prof_call());
log().verbose("Overhead per pop {1:11}", overhead_per_pop );
log().verbose("");
for (auto &entry : m_devices)

View File

@ -1097,9 +1097,9 @@ namespace netlist
void set_default_delegate(detail::core_terminal_t &term);
/* stats */
nperftime_t m_stat_total_time;
nperfcount_t m_stat_call_count;
nperfcount_t m_stat_inc_active;
nperftime_t<NL_KEEP_STATISTICS> m_stat_total_time;
nperfcount_t<NL_KEEP_STATISTICS> m_stat_call_count;
nperfcount_t<NL_KEEP_STATISTICS> m_stat_inc_active;
protected:
@ -1193,7 +1193,7 @@ namespace netlist
* solvers will update inputs after parallel processing.
*/
class detail::queue_t :
public timed_queue<pqentry_t<net_t *, netlist_time>, false>,
public timed_queue<pqentry_t<net_t *, netlist_time>, false, NL_KEEP_STATISTICS>,
public detail::netlist_ref,
public plib::state_manager_t::callback_t
{
@ -1351,8 +1351,8 @@ namespace netlist
plib::state_manager_t m_state;
// performance
nperftime_t m_stat_mainloop;
nperfcount_t m_perf_out_processed;
nperftime_t<NL_KEEP_STATISTICS> m_stat_mainloop;
nperfcount_t<NL_KEEP_STATISTICS> m_perf_out_processed;
std::vector<plib::owned_ptr<core_device_t>> m_devices;
};

View File

@ -101,7 +101,7 @@ namespace netlist
#if !USE_HEAP
/* Use TS = true for a threadsafe queue */
template <class T, bool TS, class QueueOp = typename T::QueueOp>
template <class T, bool TS, bool KEEPSTAT, class QueueOp = typename T::QueueOp>
class timed_queue : plib::nocopyassignmove
{
public:
@ -201,8 +201,8 @@ namespace netlist
public:
// profiling
nperfcount_t m_prof_sortmove;
nperfcount_t m_prof_call;
nperfcount_t<KEEPSTAT> m_prof_sortmove;
nperfcount_t<KEEPSTAT> m_prof_call;
};
#else
template <class T, bool TS, class QueueOp = typename T::QueueOp>
@ -296,8 +296,8 @@ namespace netlist
public:
// profiling
nperfcount_t m_prof_sortmove;
nperfcount_t m_prof_call;
nperfcount_t<NL_KEEP_STATISTICS> m_prof_sortmove;
nperfcount_t<NL_KEEP_STATISTICS> m_prof_call;
};
#endif
}