summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib
diff options
context:
space:
mode:
authorTim O'Shea <tim.oshea753@gmail.com>2013-06-04 13:35:53 -0400
committerTim O'Shea <tim.oshea753@gmail.com>2013-06-05 14:20:05 -0400
commit8c5d3f8b4d2b84bb214e7f7bd6b3c0d3c60df1db (patch)
tree7468b7ab1a7a0a538dcdcd466038c681cf9cd817 /gnuradio-runtime/lib
parent5e3fd0144cd3dde787985601416f798a37ebae86 (diff)
runtime: adding config file + ctrlport selectable gr::high_res_timer to select clock type for performance counters
Diffstat (limited to 'gnuradio-runtime/lib')
-rw-r--r--gnuradio-runtime/lib/CMakeLists.txt1
-rw-r--r--gnuradio-runtime/lib/high_res_timer.cc8
-rw-r--r--gnuradio-runtime/lib/top_block.cc19
3 files changed, 28 insertions, 0 deletions
diff --git a/gnuradio-runtime/lib/CMakeLists.txt b/gnuradio-runtime/lib/CMakeLists.txt
index 29222ae91f..a7b2638c21 100644
--- a/gnuradio-runtime/lib/CMakeLists.txt
+++ b/gnuradio-runtime/lib/CMakeLists.txt
@@ -83,6 +83,7 @@ list(APPEND gnuradio_runtime_sources
flowgraph.cc
hier_block2.cc
hier_block2_detail.cc
+ high_res_timer.cc
io_signature.cc
local_sighandler.cc
logger.cc
diff --git a/gnuradio-runtime/lib/high_res_timer.cc b/gnuradio-runtime/lib/high_res_timer.cc
new file mode 100644
index 0000000000..37e7e322a8
--- /dev/null
+++ b/gnuradio-runtime/lib/high_res_timer.cc
@@ -0,0 +1,8 @@
+#include <gnuradio/high_res_timer.h>
+
+#ifdef GNURADIO_HRT_USE_CLOCK_GETTIME
+clockid_t gr::high_res_timer_source = CLOCK_THREAD_CPUTIME_ID;
+#endif
+
+
+
diff --git a/gnuradio-runtime/lib/top_block.cc b/gnuradio-runtime/lib/top_block.cc
index 8d2e42bb12..0cffbcadee 100644
--- a/gnuradio-runtime/lib/top_block.cc
+++ b/gnuradio-runtime/lib/top_block.cc
@@ -28,6 +28,7 @@
#include <gnuradio/top_block.h>
#include <gnuradio/io_signature.h>
#include <gnuradio/prefs.h>
+#include <gnuradio/high_res_timer.h>
#include <unistd.h>
#include <iostream>
@@ -152,6 +153,24 @@ namespace gr {
RPC_PRIVLVL_MIN, DISPNULL)));
}
+#ifdef GNURADIO_HRT_USE_CLOCK_GETTIME
+ std::string initial_clock = prefs::singleton()->get_string("PerfCounters", "clock", "thread");
+ if(initial_clock.compare("thread") == 0){
+ gr::high_res_timer_source = CLOCK_THREAD_CPUTIME_ID;
+ } else if(initial_clock.compare("monotonic") == 0){
+ gr::high_res_timer_source = CLOCK_MONOTONIC;
+ } else {
+ throw std::runtime_error("bad argument for PerfCounters.clock!");
+ }
+ add_rpc_variable(
+ rpcbasic_sptr(new rpcbasic_register_variable_rw<int>(
+ alias(), "perfcounter_clock",
+ (int*)&gr::high_res_timer_source,
+ pmt::mp(0), pmt::mp(2), pmt::mp(2),
+ "clock", "Performance Counters Realtime Clock Type",
+ RPC_PRIVLVL_MIN, DISPNULL)));
+#endif
+
// Setters
add_rpc_variable(
rpcbasic_sptr(new rpcbasic_register_set<top_block, int>(