diff options
Diffstat (limited to 'gnuradio-core')
-rw-r--r-- | gnuradio-core/gnuradio-core.conf | 3 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_prefs.cc | 152 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_prefs.h | 10 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_prefs.i | 3 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_file_source.cc | 1 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_message_debug.cc | 9 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_message_debug.h | 13 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block.cc | 85 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block.h | 41 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block.i | 9 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_detail.cc | 137 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_detail.h | 15 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_executor.cc | 12 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_executor.h | 4 | ||||
-rw-r--r-- | gnuradio-core/src/python/gnuradio/gr/__init__.py | 2 | ||||
-rwxr-xr-x | gnuradio-core/src/python/gnuradio/gr/qa_pdu.py | 2 |
16 files changed, 462 insertions, 36 deletions
diff --git a/gnuradio-core/gnuradio-core.conf b/gnuradio-core/gnuradio-core.conf index 178b288e8..70eb00236 100644 --- a/gnuradio-core/gnuradio-core.conf +++ b/gnuradio-core/gnuradio-core.conf @@ -5,3 +5,6 @@ [DEFAULT] verbose = False + +[PerfCounters] +on = False diff --git a/gnuradio-core/src/lib/general/gr_prefs.cc b/gnuradio-core/src/lib/general/gr_prefs.cc index 20aead8e3..953143bc5 100644 --- a/gnuradio-core/src/lib/general/gr_prefs.cc +++ b/gnuradio-core/src/lib/general/gr_prefs.cc @@ -25,6 +25,14 @@ #endif #include <gr_prefs.h> +#include <gr_sys_paths.h> +#include <gr_constants.h> +#include <algorithm> + +#include <boost/filesystem/operations.hpp> +#include <boost/filesystem/path.hpp> +#include <boost/filesystem/fstream.hpp> +namespace fs = boost::filesystem; /* * Stub implementations @@ -45,44 +53,176 @@ gr_prefs::set_singleton(gr_prefs *p) s_singleton = p; } +gr_prefs::gr_prefs() +{ + _read_files(); +} + gr_prefs::~gr_prefs() { // nop } +std::vector<std::string> +gr_prefs::_sys_prefs_filenames() +{ + std::vector<std::string> fnames; + + fs::path dir = gr_prefsdir(); + if(!fs::is_directory(dir)) + return fnames; + + fs::directory_iterator diritr(dir); + while(diritr != fs::directory_iterator()) { + fs::path p = *diritr++; + fnames.push_back(p.string()); + } + std::sort(fnames.begin(), fnames.end()); + + // Find if there is a ~/.gnuradio/config file and add this to the + // beginning of the file list to override any preferences in the + // installed path config files. + fs::path homedir = fs::path(gr_appdata_path()); + homedir /= ".gnuradio/config.conf"; + if(fs::exists(homedir)) { + fnames.insert(fnames.begin(), homedir.string()); + } + + return fnames; +} + +void +gr_prefs::_read_files() +{ + std::vector<std::string> filenames = _sys_prefs_filenames(); + std::vector<std::string>::iterator sitr; + char tmp[1024]; + for(sitr = filenames.begin(); sitr != filenames.end(); sitr++) { + fs::ifstream fin(*sitr); + while(!fin.eof()) { + fin.getline(tmp, 1024); + std::string t(tmp); + // ignore empty lines or lines of just comments + if((t.size() > 0) && (t[0] != '#')) { + // remove any comments in the line + size_t hash = t.find("#"); + + // Use hash marks at the end of each segment as a delimiter + d_configs += t.substr(0, hash) + '#'; + } + } + fin.close(); + } + + // Remove all whitespace + d_configs.erase(std::remove_if(d_configs.begin(), d_configs.end(), ::isspace), d_configs.end()); +} + bool gr_prefs::has_section(const std::string section) { - return false; + size_t t = d_configs.find("[" + section + "]#"); + return t != std::string::npos; } bool gr_prefs::has_option(const std::string section, const std::string option) { - return false; + if(has_section(section)) { + size_t sec = d_configs.find("[" + section + "]#"); + size_t opt = d_configs.find("#" + option + "=", sec); + return opt != std::string::npos; + } + else { + return false; + } } const std::string gr_prefs::get_string(const std::string section, const std::string option, const std::string default_val) { - return default_val; + std::stringstream envname; + std::string secname=section, optname=option; + + std::transform(section.begin(), section.end(), secname.begin(), ::toupper); + std::transform(option.begin(), option.end(), optname.begin(), ::toupper); + envname << "GR_CONF_" << secname << "_" << optname; + + char *v = getenv(envname.str().c_str()); + if(v) { + return std::string(v); + } + + if(has_option(section, option)) { + std::string optname = "#" + option + "="; + size_t sec = d_configs.find("[" + section + "]#"); + size_t opt = d_configs.find(optname, sec); + + size_t start = opt + optname.size(); + size_t end = d_configs.find("#", start); + size_t len = end - start; + + return d_configs.substr(start, len); + } + else { + return default_val; + } } bool gr_prefs::get_bool(const std::string section, const std::string option, bool default_val) { - return default_val; + if(has_option(section, option)) { + std::string str = get_string(section, option, ""); + if(str == "") { + return default_val; + } + std::transform(str.begin(), str.end(), str.begin(), ::tolower); + if((str == "true") || (str == "on") || (str == "1")) + return true; + else if((str == "false") || (str == "off") || (str == "0")) + return false; + else + return default_val; + } + else { + return default_val; + } } long gr_prefs::get_long(const std::string section, const std::string option, long default_val) { - return default_val; + if(has_option(section, option)) { + std::string str = get_string(section, option, ""); + if(str == "") { + return default_val; + } + std::stringstream sstr(str); + long n; + sstr >> n; + return n; + } + else { + return default_val; + } } double gr_prefs::get_double(const std::string section, const std::string option, double default_val) { - return default_val; + if(has_option(section, option)) { + std::string str = get_string(section, option, ""); + if(str == "") { + return default_val; + } + std::stringstream sstr(str); + double n; + sstr >> n; + return n; + } + else { + return default_val; + } } diff --git a/gnuradio-core/src/lib/general/gr_prefs.h b/gnuradio-core/src/lib/general/gr_prefs.h index b1c354bd3..90d602741 100644 --- a/gnuradio-core/src/lib/general/gr_prefs.h +++ b/gnuradio-core/src/lib/general/gr_prefs.h @@ -24,6 +24,7 @@ #include <gr_core_api.h> #include <string> +#include <gruel/thread.h> /*! * \brief Base class for representing user preferences a la windows INI files. @@ -39,6 +40,7 @@ public: static gr_prefs *singleton(); static void set_singleton(gr_prefs *p); + gr_prefs(); virtual ~gr_prefs(); /*! @@ -78,6 +80,14 @@ public: virtual double get_double(const std::string section, const std::string option, double default_val); + + protected: + virtual std::vector<std::string> _sys_prefs_filenames(); + virtual void _read_files(); + + private: + gruel::mutex d_mutex; + std::string d_configs; }; diff --git a/gnuradio-core/src/lib/general/gr_prefs.i b/gnuradio-core/src/lib/general/gr_prefs.i index f44dcc944..cfb4cdb4e 100644 --- a/gnuradio-core/src/lib/general/gr_prefs.i +++ b/gnuradio-core/src/lib/general/gr_prefs.i @@ -20,9 +20,6 @@ * Boston, MA 02110-1301, USA. */ -// Generate SWIG directors for gr_prefs. -%feature("director") gr_prefs; - class gr_prefs { public: diff --git a/gnuradio-core/src/lib/io/gr_file_source.cc b/gnuradio-core/src/lib/io/gr_file_source.cc index f3def0721..6da7abac2 100644 --- a/gnuradio-core/src/lib/io/gr_file_source.cc +++ b/gnuradio-core/src/lib/io/gr_file_source.cc @@ -24,6 +24,7 @@ #include "config.h" #endif +#include <gruel/thread.h> #include <gr_file_source.h> #include <gr_io_signature.h> #include <cstdio> diff --git a/gnuradio-core/src/lib/io/gr_message_debug.cc b/gnuradio-core/src/lib/io/gr_message_debug.cc index 1327c31ba..9eb1bb639 100644 --- a/gnuradio-core/src/lib/io/gr_message_debug.cc +++ b/gnuradio-core/src/lib/io/gr_message_debug.cc @@ -59,10 +59,10 @@ gr_message_debug::store(pmt::pmt_t msg) } void -gr_message_debug::print_verbose(pmt::pmt_t msg) +gr_message_debug::print_pdu(pmt::pmt_t pdu) { - pmt::pmt_t meta = pmt::pmt_car(msg); - pmt::pmt_t vector = pmt::pmt_cdr(msg); + pmt::pmt_t meta = pmt::pmt_car(pdu); + pmt::pmt_t vector = pmt::pmt_cdr(pdu); std::cout << "* MESSAGE DEBUG PRINT PDU VERBOSE *\n"; pmt::pmt_print(meta); size_t len = pmt::pmt_length(vector); @@ -110,6 +110,9 @@ gr_message_debug::gr_message_debug() message_port_register_in(pmt::mp("store")); set_msg_handler(pmt::mp("store"), boost::bind(&gr_message_debug::store, this, _1)); + + message_port_register_in(pmt::mp("print_pdu")); + set_msg_handler(pmt::mp("print_pdu"), boost::bind(&gr_message_debug::print_pdu, this, _1)); } gr_message_debug::~gr_message_debug() diff --git a/gnuradio-core/src/lib/io/gr_message_debug.h b/gnuradio-core/src/lib/io/gr_message_debug.h index 6e6e5103c..f1374e806 100644 --- a/gnuradio-core/src/lib/io/gr_message_debug.h +++ b/gnuradio-core/src/lib/io/gr_message_debug.h @@ -55,7 +55,18 @@ class GR_CORE_API gr_message_debug : public gr_block * \param msg A pmt message passed from the scheduler's message handling. */ void print(pmt::pmt_t msg); - void print_verbose(pmt::pmt_t msg); + + /*! + * \brief PDU formatted messages received in this port are printed to stdout. + * + * This port receives messages from the scheduler's message handling + * mechanism and prints it to stdout. This message handler function + * is only meant to be used by the scheduler to handle messages + * posted to port 'print'. + * + * \param pdu A PDU message passed from the scheduler's message handling. + */ + void print_pdu(pmt::pmt_t pdu); /*! * \brief Messages received in this port are stored in a vector. diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc b/gnuradio-core/src/lib/runtime/gr_block.cc index f52f7a6ba..54d267620 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_block.cc @@ -282,6 +282,17 @@ gr_block::pc_noutput_items() } float +gr_block::pc_noutput_items_var() +{ + if(d_detail) { + return d_detail->pc_noutput_items_var(); + } + else { + return 0; + } +} + +float gr_block::pc_nproduced() { if(d_detail) { @@ -293,6 +304,17 @@ gr_block::pc_nproduced() } float +gr_block::pc_nproduced_var() +{ + if(d_detail) { + return d_detail->pc_nproduced_var(); + } + else { + return 0; + } +} + +float gr_block::pc_input_buffers_full(int which) { if(d_detail) { @@ -303,6 +325,17 @@ gr_block::pc_input_buffers_full(int which) } } +float +gr_block::pc_input_buffers_full_var(int which) +{ + if(d_detail) { + return d_detail->pc_input_buffers_full_var(static_cast<size_t>(which)); + } + else { + return 0; + } +} + std::vector<float> gr_block::pc_input_buffers_full() { @@ -314,6 +347,17 @@ gr_block::pc_input_buffers_full() } } +std::vector<float> +gr_block::pc_input_buffers_full_var() +{ + if(d_detail) { + return d_detail->pc_input_buffers_full_var(); + } + else { + return std::vector<float>(1,0); + } +} + float gr_block::pc_output_buffers_full(int which) { @@ -325,6 +369,17 @@ gr_block::pc_output_buffers_full(int which) } } +float +gr_block::pc_output_buffers_full_var(int which) +{ + if(d_detail) { + return d_detail->pc_output_buffers_full_var(static_cast<size_t>(which)); + } + else { + return 0; + } +} + std::vector<float> gr_block::pc_output_buffers_full() { @@ -336,6 +391,17 @@ gr_block::pc_output_buffers_full() } } +std::vector<float> +gr_block::pc_output_buffers_full_var() +{ + if(d_detail) { + return d_detail->pc_output_buffers_full_var(); + } + else { + return std::vector<float>(1,0); + } +} + float gr_block::pc_work_time() { @@ -347,6 +413,25 @@ gr_block::pc_work_time() } } +float +gr_block::pc_work_time_var() +{ + if(d_detail) { + return d_detail->pc_work_time_var(); + } + else { + return 0; + } +} + +void +gr_block::reset_perf_counters() +{ + if(d_detail) { + d_detail->reset_perf_counters(); + } +} + std::ostream& operator << (std::ostream& os, const gr_block *m) { diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index bd9ff42df..6e21d5b97 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -383,35 +383,74 @@ class GR_CORE_API gr_block : public gr_basic_block { float pc_noutput_items(); /*! + * \brief Gets variance of noutput_items performance counter. + */ + float pc_noutput_items_var(); + + /*! * \brief Gets average num items produced performance counter. */ float pc_nproduced(); /*! - * \brief Gets average average fullness of \p which input buffer. + * \brief Gets variance of num items produced performance counter. + */ + float pc_nproduced_var(); + + /*! + * \brief Gets average fullness of \p which input buffer. */ float pc_input_buffers_full(int which); /*! + * \brief Gets variance of fullness of \p which input buffer. + */ + float pc_input_buffers_full_var(int which); + + /*! * \brief Gets average fullness of all input buffers. */ std::vector<float> pc_input_buffers_full(); /*! + * \brief Gets variance of fullness of all input buffers. + */ + std::vector<float> pc_input_buffers_full_var(); + + /*! * \brief Gets average fullness of \p which input buffer. */ float pc_output_buffers_full(int which); /*! + * \brief Gets variance of fullness of \p which input buffer. + */ + float pc_output_buffers_full_var(int which); + + /*! * \brief Gets average fullness of all output buffers. */ std::vector<float> pc_output_buffers_full(); + /*! + * \brief Gets variance of fullness of all output buffers. + */ + std::vector<float> pc_output_buffers_full_var(); /*! * \brief Gets average clock cycles spent in work. */ float pc_work_time(); + /*! + * \brief Gets average clock cycles spent in work. + */ + float pc_work_time_var(); + + /*! + * \brief Resets the performance counters + */ + void reset_perf_counters(); + // ---------------------------------------------------------------------------- // Functions to handle thread affinity diff --git a/gnuradio-core/src/lib/runtime/gr_block.i b/gnuradio-core/src/lib/runtime/gr_block.i index c016f2c28..a80f64d02 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.i +++ b/gnuradio-core/src/lib/runtime/gr_block.i @@ -68,13 +68,20 @@ class gr_block : public gr_basic_block { // Methods to access performance counters float pc_noutput_items(); + float pc_noutput_items_var(); float pc_nproduced(); + float pc_nproduced_var(); float pc_input_buffers_full(int which); + float pc_input_buffers_full_var(int which); std::vector<float> pc_input_buffers_full(); + std::vector<float> pc_input_buffers_full_var(); float pc_output_buffers_full(int which); + float pc_output_buffers_full_var(int which); std::vector<float> pc_output_buffers_full(); + std::vector<float> pc_output_buffers_full_var(); float pc_work_time(); - + float pc_work_time_var(); + // Methods to manage processor affinity. void set_processor_affinity(const gr_vector_uint &mask); void unset_processor_affinity(); diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.cc b/gnuradio-core/src/lib/runtime/gr_block_detail.cc index ff20e0e85..82081039a 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.cc @@ -43,10 +43,17 @@ gr_block_detail::gr_block_detail (unsigned int ninputs, unsigned int noutputs) d_ninputs (ninputs), d_noutputs (noutputs), d_input (ninputs), d_output (noutputs), d_done (false), - d_avg_noutput_items(0), d_avg_nproduced(0), + d_avg_noutput_items(0), + d_var_noutput_items(0), + d_avg_nproduced(0), + d_var_nproduced(0), d_avg_input_buffers_full(ninputs, 0), + d_var_input_buffers_full(ninputs, 0), d_avg_output_buffers_full(noutputs, 0), - d_avg_work_time(0) + d_var_output_buffers_full(noutputs, 0), + d_avg_work_time(0), + d_var_work_time(0), + d_pc_counter(0) { s_ncurrently_allocated++; } @@ -237,27 +244,68 @@ gr_block_detail::start_perf_counters() void gr_block_detail::stop_perf_counters(int noutput_items, int nproduced) { - float alpha = 0.05; - float beta = 1.0-alpha; - d_end_of_work = gruel::high_res_timer_now(); gruel::high_res_timer_type diff = d_end_of_work - d_start_of_work; - d_avg_work_time = beta*d_avg_work_time + alpha*diff; - - d_avg_nproduced = beta*d_avg_nproduced + alpha*nproduced; - d_avg_noutput_items = beta*d_avg_noutput_items + alpha*noutput_items; - for(size_t i=0; i < d_input.size(); i++) { - float pfull = static_cast<float>(d_input[i]->items_available()) / - static_cast<float>(d_input[i]->max_possible_items_available()); - d_avg_input_buffers_full[i] = beta*d_avg_input_buffers_full[i] + alpha*pfull; + if(d_pc_counter == 0) { + d_avg_work_time = diff; + d_var_work_time = 0; + d_avg_nproduced = nproduced; + d_var_nproduced = 0; + d_avg_noutput_items = noutput_items; + d_var_noutput_items = 0; + for(size_t i=0; i < d_input.size(); i++) { + float pfull = static_cast<float>(d_input[i]->items_available()) / + static_cast<float>(d_input[i]->max_possible_items_available()); + d_avg_input_buffers_full[i] = pfull; + d_var_input_buffers_full[i] = 0; + } + for(size_t i=0; i < d_output.size(); i++) { + float pfull = 1.0f - static_cast<float>(d_output[i]->space_available()) / + static_cast<float>(d_output[i]->bufsize()); + d_avg_output_buffers_full[i] = pfull; + d_var_output_buffers_full[i] = 0; + } } + else { + float d = diff - d_avg_work_time; + d_avg_work_time = d_avg_work_time + d/d_pc_counter; + d_var_work_time = d_var_work_time + d*d; + + d = nproduced - d_avg_nproduced; + d_avg_nproduced = d_avg_nproduced + d/d_pc_counter; + d_var_nproduced = d_var_nproduced + d*d; + + d = noutput_items - d_avg_noutput_items; + d_avg_noutput_items = d_avg_noutput_items + d/d_pc_counter; + d_var_noutput_items = d_var_noutput_items + d*d; + + for(size_t i=0; i < d_input.size(); i++) { + float pfull = static_cast<float>(d_input[i]->items_available()) / + static_cast<float>(d_input[i]->max_possible_items_available()); + + d = pfull - d_avg_input_buffers_full[i]; + d_avg_input_buffers_full[i] = d_avg_input_buffers_full[i] + d/d_pc_counter; + d_var_input_buffers_full[i] = d_var_input_buffers_full[i] + d*d; + } - for(size_t i=0; i < d_output.size(); i++) { - float pfull = 1.0f - static_cast<float>(d_output[i]->space_available()) / - static_cast<float>(d_output[i]->bufsize()); - d_avg_output_buffers_full[i] = beta*d_avg_output_buffers_full[i] + alpha*pfull; + for(size_t i=0; i < d_output.size(); i++) { + float pfull = 1.0f - static_cast<float>(d_output[i]->space_available()) / + static_cast<float>(d_output[i]->bufsize()); + + d = pfull - d_avg_output_buffers_full[i]; + d_avg_output_buffers_full[i] = d_avg_output_buffers_full[i] + d/d_pc_counter; + d_var_output_buffers_full[i] = d_var_output_buffers_full[i] + d*d; + } } + + d_pc_counter++; +} + +void +gr_block_detail::reset_perf_counters() +{ + d_pc_counter = 0; } float @@ -307,3 +355,58 @@ gr_block_detail::pc_work_time() { return d_avg_work_time; } + + +float +gr_block_detail::pc_noutput_items_var() +{ + return d_var_noutput_items/(d_pc_counter-1); +} + +float +gr_block_detail::pc_nproduced_var() +{ + return d_var_nproduced/(d_pc_counter-1); +} + +float +gr_block_detail::pc_input_buffers_full_var(size_t which) +{ + if(which < d_avg_input_buffers_full.size()) + return d_var_input_buffers_full[which]/(d_pc_counter-1); + else + return 0; +} + +std::vector<float> +gr_block_detail::pc_input_buffers_full_var() +{ + std::vector<float> var(d_avg_input_buffers_full.size(), 0); + for(size_t i = 0; i < d_avg_input_buffers_full.size(); i++) + var[i] = d_avg_input_buffers_full[i]/(d_pc_counter-1); + return var; +} + +float +gr_block_detail::pc_output_buffers_full_var(size_t which) +{ + if(which < d_avg_output_buffers_full.size()) + return d_var_output_buffers_full[which]/(d_pc_counter-1); + else + return 0; +} + +std::vector<float> +gr_block_detail::pc_output_buffers_full_var() +{ + std::vector<float> var(d_avg_output_buffers_full.size(), 0); + for(size_t i = 0; i < d_avg_output_buffers_full.size(); i++) + var[i] = d_avg_output_buffers_full[i]/(d_pc_counter-1); + return var; +} + +float +gr_block_detail::pc_work_time_var() +{ + return d_var_work_time/(d_pc_counter-1); +} diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.h b/gnuradio-core/src/lib/runtime/gr_block_detail.h index a8ed8da90..32a01e763 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.h +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.h @@ -173,6 +173,7 @@ class GR_CORE_API gr_block_detail { void start_perf_counters(); void stop_perf_counters(int noutput_items, int nproduced); + void reset_perf_counters(); // Calls to get performance counter items float pc_noutput_items(); @@ -182,6 +183,14 @@ class GR_CORE_API gr_block_detail { float pc_output_buffers_full(size_t which); std::vector<float> pc_output_buffers_full(); float pc_work_time(); + + float pc_noutput_items_var(); + float pc_nproduced_var(); + float pc_input_buffers_full_var(size_t which); + std::vector<float> pc_input_buffers_full_var(); + float pc_output_buffers_full_var(size_t which); + std::vector<float> pc_output_buffers_full_var(); + float pc_work_time_var(); gr_tpb_detail d_tpb; // used by thread-per-block scheduler int d_produce_or; @@ -197,11 +206,17 @@ class GR_CORE_API gr_block_detail { // Performance counters float d_avg_noutput_items; + float d_var_noutput_items; float d_avg_nproduced; + float d_var_nproduced; std::vector<float> d_avg_input_buffers_full; + std::vector<float> d_var_input_buffers_full; std::vector<float> d_avg_output_buffers_full; + std::vector<float> d_var_output_buffers_full; gruel::high_res_timer_type d_start_of_work, d_end_of_work; float d_avg_work_time; + float d_var_work_time; + float d_pc_counter; gr_block_detail (unsigned int ninputs, unsigned int noutputs); diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.cc b/gnuradio-core/src/lib/runtime/gr_block_executor.cc index 27f591452..e070f3c50 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_executor.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_executor.cc @@ -28,6 +28,7 @@ #include <gr_block.h> #include <gr_block_detail.h> #include <gr_buffer.h> +#include <gr_prefs.h> #include <boost/thread.hpp> #include <boost/format.hpp> #include <iostream> @@ -165,6 +166,11 @@ gr_block_executor::gr_block_executor (gr_block_sptr block, int max_noutput_items << d_block << std::endl; } +#ifdef GR_PERFORMANCE_COUNTERS + gr_prefs *prefs = gr_prefs::singleton(); + d_use_pc = prefs->get_bool("PerfCounters", "on", false); +#endif /* GR_PERFORMANCE_COUNTERS */ + d_block->start(); // enable any drivers, etc. } @@ -420,7 +426,8 @@ gr_block_executor::run_one_iteration() d_start_nitems_read[i] = d->nitems_read(i); #ifdef GR_PERFORMANCE_COUNTERS - d->start_perf_counters(); + if(d_use_pc) + d->start_perf_counters(); #endif /* GR_PERFORMANCE_COUNTERS */ // Do the actual work of the block @@ -428,7 +435,8 @@ gr_block_executor::run_one_iteration() d_input_items, d_output_items); #ifdef GR_PERFORMANCE_COUNTERS - d->stop_perf_counters(noutput_items, n); + if(d_use_pc) + d->stop_perf_counters(noutput_items, n); #endif /* GR_PERFORMANCE_COUNTERS */ LOG(*d_log << " general_work: noutput_items = " << noutput_items diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.h b/gnuradio-core/src/lib/runtime/gr_block_executor.h index 0ae5affba..fb7f9c269 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_executor.h +++ b/gnuradio-core/src/lib/runtime/gr_block_executor.h @@ -53,6 +53,10 @@ protected: std::vector<gr_tag_t> d_returned_tags; int d_max_noutput_items; +#ifdef GR_PERFORMANCE_COUNTERS + bool d_use_pc; +#endif /* GR_PERFORMANCE_COUNTERS */ + public: gr_block_executor(gr_block_sptr block, int max_noutput_items=100000); ~gr_block_executor (); diff --git a/gnuradio-core/src/python/gnuradio/gr/__init__.py b/gnuradio-core/src/python/gnuradio/gr/__init__.py index f1b971e62..1c2c4c837 100644 --- a/gnuradio-core/src/python/gnuradio/gr/__init__.py +++ b/gnuradio-core/src/python/gnuradio/gr/__init__.py @@ -36,7 +36,7 @@ serial_to_parallel = stream_to_vector parallel_to_serial = vector_to_stream # Force the preference database to be initialized -from prefs import prefs +prefs = gr_prefs.singleton #alias old gr_add_vXX and gr_multiply_vXX add_vcc = add_cc diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pdu.py b/gnuradio-core/src/python/gnuradio/gr/qa_pdu.py index 572d8b186..c1110c10b 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_pdu.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_pdu.py @@ -46,7 +46,7 @@ class test_pdu(gr_unittest.TestCase): # Test that the right number of ports exist. pi = dbg.message_ports_in() po = dbg.message_ports_out() - self.assertEqual(pmt.pmt_length(pi), 2) + self.assertEqual(pmt.pmt_length(pi), 3) self.assertEqual(pmt.pmt_length(po), 0) pi = snk3.message_ports_in() |