[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/03: runtime: add throughput counter
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/03: runtime: add throughput counter |
Date: |
Mon, 3 Nov 2014 18:47:21 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit fe9bd1d961986fd55f6eb984939344be18cd7605
Author: Nathan West <address@hidden>
Date: Fri Oct 31 19:08:14 2014 -0500
runtime: add throughput counter
throughput_avg is calculated with a wall clock timer over all items
produced.
---
gnuradio-runtime/include/gnuradio/block.h | 5 +++++
gnuradio-runtime/include/gnuradio/block_detail.h | 5 +++++
gnuradio-runtime/lib/block.cc | 10 ++++++++++
gnuradio-runtime/lib/block_detail.cc | 13 +++++++++++++
gnuradio-runtime/swig/block.i | 1 +
5 files changed, 34 insertions(+)
diff --git a/gnuradio-runtime/include/gnuradio/block.h
b/gnuradio-runtime/include/gnuradio/block.h
index 3affb6f..4a534b7 100644
--- a/gnuradio-runtime/include/gnuradio/block.h
+++ b/gnuradio-runtime/include/gnuradio/block.h
@@ -504,6 +504,11 @@ namespace gr {
float pc_work_time_total();
/*!
+ * \brief Gets average throughput.
+ */
+ float pc_throughput_avg();
+
+ /*!
* \brief Resets the performance counters
*/
void reset_perf_counters();
diff --git a/gnuradio-runtime/include/gnuradio/block_detail.h
b/gnuradio-runtime/include/gnuradio/block_detail.h
index 41568c8..916c0a4 100644
--- a/gnuradio-runtime/include/gnuradio/block_detail.h
+++ b/gnuradio-runtime/include/gnuradio/block_detail.h
@@ -219,6 +219,7 @@ namespace gr {
float pc_output_buffers_full_avg(size_t which);
std::vector<float> pc_output_buffers_full_avg();
float pc_work_time_avg();
+ float pc_throughput_avg();
float pc_noutput_items_var();
float pc_nproduced_var();
@@ -246,6 +247,9 @@ namespace gr {
float d_ins_noutput_items;
float d_avg_noutput_items;
float d_var_noutput_items;
+ float d_total_noutput_items;
+ gr::high_res_timer_type d_pc_start_time;
+ gr::high_res_timer_type d_pc_last_work_time;
float d_ins_nproduced;
float d_avg_nproduced;
float d_var_nproduced;
@@ -260,6 +264,7 @@ namespace gr {
float d_avg_work_time;
float d_var_work_time;
float d_total_work_time;
+ float d_avg_throughput;
float d_pc_counter;
block_detail(unsigned int ninputs, unsigned int noutputs);
diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc
index a15fb89..2cc868e 100644
--- a/gnuradio-runtime/lib/block.cc
+++ b/gnuradio-runtime/lib/block.cc
@@ -682,6 +682,16 @@ namespace gr {
}
}
+ float
+ block::pc_throughput_avg() {
+ if(d_detail) {
+ return d_detail->pc_throughput_avg();
+ }
+ else {
+ return 0;
+ }
+ }
+
void
block::reset_perf_counters()
{
diff --git a/gnuradio-runtime/lib/block_detail.cc
b/gnuradio-runtime/lib/block_detail.cc
index 77c457c..9463e8d 100644
--- a/gnuradio-runtime/lib/block_detail.cc
+++ b/gnuradio-runtime/lib/block_detail.cc
@@ -46,6 +46,7 @@ namespace gr {
d_ins_noutput_items(0),
d_avg_noutput_items(0),
d_var_noutput_items(0),
+ d_total_noutput_items(0),
d_ins_nproduced(0),
d_avg_nproduced(0),
d_var_nproduced(0),
@@ -58,9 +59,11 @@ namespace gr {
d_ins_work_time(0),
d_avg_work_time(0),
d_var_work_time(0),
+ d_avg_throughput(0),
d_pc_counter(0)
{
s_ncurrently_allocated++;
+ d_pc_start_time = gr::high_res_timer_now();
}
block_detail::~block_detail()
@@ -279,6 +282,8 @@ namespace gr {
d_ins_noutput_items = noutput_items;
d_avg_noutput_items = noutput_items;
d_var_noutput_items = 0;
+ d_total_noutput_items = noutput_items;
+ d_pc_start_time = (float)gr::high_res_timer_now();
for(size_t i=0; i < d_input.size(); i++) {
gr::thread::scoped_lock guard(*d_input[i]->mutex());
float pfull = static_cast<float>(d_input[i]->items_available()) /
@@ -312,6 +317,10 @@ namespace gr {
d_ins_noutput_items = noutput_items;
d_avg_noutput_items = d_avg_noutput_items + d/d_pc_counter;
d_var_noutput_items = d_var_noutput_items + d*d;
+ d_total_noutput_items += noutput_items;
+ d_pc_last_work_time = gr::high_res_timer_now();
+ float monitor_time = (float)(d_pc_last_work_time - d_pc_start_time) /
(float)gr::high_res_timer_tps();
+ d_avg_throughput = d_total_noutput_items / monitor_time;
for(size_t i=0; i < d_input.size(); i++) {
gr::thread::scoped_lock guard(*d_input[i]->mutex());
@@ -501,4 +510,8 @@ namespace gr {
return d_total_work_time;
}
+ float
+ block_detail::pc_throughput_avg() {
+ return d_avg_throughput;
+ }
} /* namespace gr */
diff --git a/gnuradio-runtime/swig/block.i b/gnuradio-runtime/swig/block.i
index 9f3f374..945cea7 100644
--- a/gnuradio-runtime/swig/block.i
+++ b/gnuradio-runtime/swig/block.i
@@ -96,6 +96,7 @@ class gr::block : public gr::basic_block
float pc_work_time_avg();
float pc_work_time_var();
float pc_work_time_total();
+ float pc_throughput_avg();
// Methods to manage processor affinity.
void set_processor_affinity(const std::vector<int> &mask);