From ebf29432404347dfcc9239cf842d3527b4daae20 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 4 Jun 2019 16:55:38 +0200 Subject: [PATCH] update VILLAScommon submodule --- common | 2 +- include/villas/stats.h | 2 +- lib/api/actions/restart.cpp | 2 +- lib/api/actions/shutdown.cpp | 2 +- lib/formats/csv.cpp | 2 + lib/formats/protobuf.cpp | 2 + lib/hooks/dp.cpp | 1 + lib/io.cpp | 2 + lib/kernel/if.cpp | 2 + lib/kernel/tc_netem.cpp | 2 + lib/mapping.cpp | 2 + lib/memory/heap.cpp | 2 + lib/memory/hugepage.cpp | 2 + lib/memory/ib.cpp | 2 + lib/memory/managed.cpp | 2 + lib/node.cpp | 2 + lib/node_direction.cpp | 2 + lib/nodes/amqp.cpp | 2 + lib/nodes/comedi.cpp | 2 + lib/nodes/file.cpp | 2 + lib/nodes/iec61850.cpp | 2 + lib/nodes/iec61850_sv.cpp | 2 + lib/nodes/infiniband.cpp | 2 + lib/nodes/influxdb.cpp | 4 +- lib/nodes/loopback.cpp | 4 +- lib/nodes/mqtt.cpp | 2 + lib/nodes/nanomsg.cpp | 2 + lib/nodes/ngsi.cpp | 2 + lib/nodes/rtp.cpp | 1 + lib/nodes/shmem.cpp | 2 + lib/nodes/signal_generator.cpp | 4 +- lib/nodes/socket.cpp | 1 + lib/nodes/stats.cpp | 1 + lib/nodes/test_rtt.cpp | 2 + lib/nodes/uldaq.cpp | 2 + lib/nodes/websocket.cpp | 2 + lib/nodes/zeromq.cpp | 2 + lib/path.cpp | 1 + lib/sample.cpp | 2 + lib/signal.cpp | 2 + lib/socket_addr.cpp | 2 + lib/stats.cpp | 75 ++++++++++++++++++---------------- lib/super_node.cpp | 1 + src/villas-test-rtt.cpp | 20 +++------ 44 files changed, 122 insertions(+), 57 deletions(-) diff --git a/common b/common index a5aece6b7..da710c8ec 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit a5aece6b78d5472119d40368ede23a53782faaaf +Subproject commit da710c8ec3e94b810fe6bb8a98b0ac1debcdcf26 diff --git a/include/villas/stats.h b/include/villas/stats.h index 0668f3243..231398f60 100644 --- a/include/villas/stats.h +++ b/include/villas/stats.h @@ -88,7 +88,7 @@ struct stats_type_description { struct stats { enum state state; - struct hist histograms[STATS_METRIC_COUNT]; + villas::Hist histograms[STATS_METRIC_COUNT]; }; extern struct stats_metric_description stats_metrics[]; diff --git a/lib/api/actions/restart.cpp b/lib/api/actions/restart.cpp index fb50d452b..97aef50f3 100644 --- a/lib/api/actions/restart.cpp +++ b/lib/api/actions/restart.cpp @@ -99,7 +99,7 @@ public: return ret; /* Properly terminate current instance */ - killme(SIGTERM); + utils::killme(SIGTERM); return 0; } diff --git a/lib/api/actions/shutdown.cpp b/lib/api/actions/shutdown.cpp index 06749c046..9af911dc2 100644 --- a/lib/api/actions/shutdown.cpp +++ b/lib/api/actions/shutdown.cpp @@ -36,7 +36,7 @@ public: virtual int execute(json_t *args, json_t **resp) { - killme(SIGTERM); + utils::killme(SIGTERM); return 0; } diff --git a/lib/formats/csv.cpp b/lib/formats/csv.cpp index e6c98275e..2960e5b1a 100644 --- a/lib/formats/csv.cpp +++ b/lib/formats/csv.cpp @@ -31,6 +31,8 @@ #include #include +using namespace villas::utils; + static size_t csv_sprint_single(struct io *io, char *buf, size_t len, const struct sample *smp) { size_t off = 0; diff --git a/lib/formats/protobuf.cpp b/lib/formats/protobuf.cpp index a4ada3943..f2c58e99e 100644 --- a/lib/formats/protobuf.cpp +++ b/lib/formats/protobuf.cpp @@ -29,6 +29,8 @@ #include #include +using namespace villas::utils; + static enum signal_type protobuf_detect_format(Villas__Node__Value *val) { switch (val->value_case) { diff --git a/lib/hooks/dp.cpp b/lib/hooks/dp.cpp index a7bd08629..d5fc6fd4c 100644 --- a/lib/hooks/dp.cpp +++ b/lib/hooks/dp.cpp @@ -35,6 +35,7 @@ #include using namespace std::complex_literals; +using namespace villas::utils; namespace villas { namespace node { diff --git a/lib/io.cpp b/lib/io.cpp index 3a3783c05..98da97394 100644 --- a/lib/io.cpp +++ b/lib/io.cpp @@ -31,6 +31,8 @@ #include #include +using namespace villas::utils; + static int io_print_lines(struct io *io, struct sample *smps[], unsigned cnt) { int ret; diff --git a/lib/kernel/if.cpp b/lib/kernel/if.cpp index 061823d44..01154721a 100644 --- a/lib/kernel/if.cpp +++ b/lib/kernel/if.cpp @@ -38,6 +38,8 @@ #include +using namespace villas::utils; + int if_init(struct interface *i, struct rtnl_link *link) { i->nl_link = link; diff --git a/lib/kernel/tc_netem.cpp b/lib/kernel/tc_netem.cpp index 94105072b..3df26e03e 100644 --- a/lib/kernel/tc_netem.cpp +++ b/lib/kernel/tc_netem.cpp @@ -34,6 +34,8 @@ #include #include +using namespace villas::utils; + static const double max_percent_value = 0xffffffff; int tc_netem_parse(struct rtnl_qdisc **netem, json_t *cfg) diff --git a/lib/mapping.cpp b/lib/mapping.cpp index c68b91e90..45e77e8fc 100644 --- a/lib/mapping.cpp +++ b/lib/mapping.cpp @@ -29,6 +29,8 @@ #include #include +using namespace villas::utils; + int mapping_parse_str(struct mapping_entry *me, const char *str, struct vlist *nodes) { char *cpy, *node, *type, *field, *end, *lasts; diff --git a/lib/memory/heap.cpp b/lib/memory/heap.cpp index 8addeca38..e3085c4a5 100644 --- a/lib/memory/heap.cpp +++ b/lib/memory/heap.cpp @@ -25,6 +25,8 @@ #include #include +using namespace villas::utils; + static struct memory_allocation * memory_heap_alloc(struct memory_type *m, size_t len, size_t alignment) { int ret; diff --git a/lib/memory/hugepage.cpp b/lib/memory/hugepage.cpp index 1b0383ed3..64fbfe81e 100644 --- a/lib/memory/hugepage.cpp +++ b/lib/memory/hugepage.cpp @@ -42,6 +42,8 @@ #include #include +using namespace villas::utils; + static size_t pgsz = -1; static size_t hugepgsz = -1; diff --git a/lib/memory/ib.cpp b/lib/memory/ib.cpp index fba1fefef..ddeaf4b09 100644 --- a/lib/memory/ib.cpp +++ b/lib/memory/ib.cpp @@ -27,6 +27,8 @@ #include #include +using namespace villas::utils; + struct ibv_mr * memory_ib_get_mr(void *ptr) { struct memory_allocation *ma; diff --git a/lib/memory/managed.cpp b/lib/memory/managed.cpp index 03d9b8974..c2631929f 100644 --- a/lib/memory/managed.cpp +++ b/lib/memory/managed.cpp @@ -34,6 +34,8 @@ #include #include +using namespace villas::utils; + static struct memory_allocation * memory_managed_alloc(struct memory_type *m, size_t len, size_t alignment) { /* Simple first-fit allocation */ diff --git a/lib/node.cpp b/lib/node.cpp index 950d4a30c..a2b9bbd94 100644 --- a/lib/node.cpp +++ b/lib/node.cpp @@ -43,6 +43,8 @@ #include #endif /* WITH_NETEM */ +using namespace villas::utils; + int node_init(struct node *n, struct node_type *vt) { int ret; diff --git a/lib/node_direction.cpp b/lib/node_direction.cpp index eef6dbcb6..d79ed2841 100644 --- a/lib/node_direction.cpp +++ b/lib/node_direction.cpp @@ -28,6 +28,8 @@ #include #include +using namespace villas::utils; + int node_direction_prepare(struct node_direction *nd, struct node *n) { assert(nd->state == STATE_CHECKED); diff --git a/lib/nodes/amqp.cpp b/lib/nodes/amqp.cpp index 1a485b71d..18f255213 100644 --- a/lib/nodes/amqp.cpp +++ b/lib/nodes/amqp.cpp @@ -30,6 +30,8 @@ #include #include +using namespace villas::utils; + static void amqp_default_ssl_info(struct amqp_ssl_info *s) { s->verify_peer = 1; diff --git a/lib/nodes/comedi.cpp b/lib/nodes/comedi.cpp index 6c2e7c2c1..8ecb0c815 100644 --- a/lib/nodes/comedi.cpp +++ b/lib/nodes/comedi.cpp @@ -31,6 +31,8 @@ #include #include +using namespace villas::utils; + /* Utility functions to dump a comedi_cmd graciously taken from comedilib demo */ static char* comedi_cmd_trigger_src(unsigned int src, char *buf); static void comedi_dump_cmd(comedi_cmd *cmd, int debug_level); diff --git a/lib/nodes/file.cpp b/lib/nodes/file.cpp index 9dccea6e6..403e98d9c 100644 --- a/lib/nodes/file.cpp +++ b/lib/nodes/file.cpp @@ -34,6 +34,8 @@ #include #include +using namespace villas::utils; + static char * file_format_name(const char *format, struct timespec *ts) { struct tm tm; diff --git a/lib/nodes/iec61850.cpp b/lib/nodes/iec61850.cpp index 3ba2115ac..631153d60 100644 --- a/lib/nodes/iec61850.cpp +++ b/lib/nodes/iec61850.cpp @@ -35,6 +35,8 @@ #define CONFIG_SV_DEFAULT_PRIORITY 4 #define CONFIG_SV_DEFAULT_VLAN_ID 0 +using namespace villas::utils; + const struct iec61850_type_descriptor type_descriptors[] = { /* name, iec_type, type, size, supported */ { "boolean", iec61850_type::BOOLEAN, SIGNAL_TYPE_BOOLEAN, 1, false, false }, diff --git a/lib/nodes/iec61850_sv.cpp b/lib/nodes/iec61850_sv.cpp index c8c634039..4b563a0c0 100644 --- a/lib/nodes/iec61850_sv.cpp +++ b/lib/nodes/iec61850_sv.cpp @@ -36,6 +36,8 @@ #define CONFIG_SV_DEFAULT_PRIORITY 4 #define CONFIG_SV_DEFAULT_VLAN_ID 0 +using namespace villas::utils; + static void iec61850_sv_listener(SVSubscriber subscriber, void *ctx, SVSubscriber_ASDU asdu) { struct node *n = (struct node *) ctx; diff --git a/lib/nodes/infiniband.cpp b/lib/nodes/infiniband.cpp index f09f92a0f..a2a49c650 100644 --- a/lib/nodes/infiniband.cpp +++ b/lib/nodes/infiniband.cpp @@ -33,6 +33,8 @@ #include #include +using namespace villas::utils; + static int ib_disconnect(struct node *n) { struct infiniband *ib = (struct infiniband *) n->_vd; diff --git a/lib/nodes/influxdb.cpp b/lib/nodes/influxdb.cpp index 0a1024b83..05aa809a1 100644 --- a/lib/nodes/influxdb.cpp +++ b/lib/nodes/influxdb.cpp @@ -33,6 +33,8 @@ #include #include +using namespace villas::utils; + int influxdb_parse(struct node *n, json_t *json) { struct influxdb *i = (struct influxdb *) n->_vd; @@ -226,4 +228,4 @@ __attribute__((destructor(110))) static void deregister_plugin() { if (plugins.state != STATE_DESTROYED) vlist_remove_all(&plugins, &p); -} \ No newline at end of file +} diff --git a/lib/nodes/loopback.cpp b/lib/nodes/loopback.cpp index 22e438dc8..0c10fc720 100644 --- a/lib/nodes/loopback.cpp +++ b/lib/nodes/loopback.cpp @@ -28,6 +28,8 @@ #include #include +using namespace villas::utils; + int loopback_parse(struct node *n, json_t *cfg) { struct loopback *l = (struct loopback *) n->_vd; @@ -180,4 +182,4 @@ __attribute__((destructor(110))) static void deregister_plugin() { if (plugins.state != STATE_DESTROYED) vlist_remove_all(&plugins, &p); -} \ No newline at end of file +} diff --git a/lib/nodes/mqtt.cpp b/lib/nodes/mqtt.cpp index a1cf96595..f9ca8acd0 100644 --- a/lib/nodes/mqtt.cpp +++ b/lib/nodes/mqtt.cpp @@ -28,6 +28,8 @@ #include #include +using namespace villas::utils; + static void mqtt_log_cb(struct mosquitto *mosq, void *userdata, int level, const char *str) { switch (level) { diff --git a/lib/nodes/nanomsg.cpp b/lib/nodes/nanomsg.cpp index ec0c3a990..c9a2a805b 100644 --- a/lib/nodes/nanomsg.cpp +++ b/lib/nodes/nanomsg.cpp @@ -29,6 +29,8 @@ #include #include +using namespace villas::utils; + int nanomsg_reverse(struct node *n) { struct nanomsg *m = (struct nanomsg *) n->_vd; diff --git a/lib/nodes/ngsi.cpp b/lib/nodes/ngsi.cpp index f922508d9..ca149017a 100644 --- a/lib/nodes/ngsi.cpp +++ b/lib/nodes/ngsi.cpp @@ -34,6 +34,8 @@ #include #include +using namespace villas::utils; + /* Some global settings */ static char *name = nullptr; diff --git a/lib/nodes/rtp.cpp b/lib/nodes/rtp.cpp index 540fa1e0d..4a2cbc2db 100644 --- a/lib/nodes/rtp.cpp +++ b/lib/nodes/rtp.cpp @@ -54,6 +54,7 @@ extern "C" { static pthread_t re_pthread; using namespace villas::node; +using namespace villas::utils; static struct plugin p; diff --git a/lib/nodes/shmem.cpp b/lib/nodes/shmem.cpp index 7ccbb5358..87dbcda8c 100644 --- a/lib/nodes/shmem.cpp +++ b/lib/nodes/shmem.cpp @@ -36,6 +36,8 @@ #include #include +using namespace villas::utils; + int shmem_parse(struct node *n, json_t *cfg) { struct shmem *shm = (struct shmem *) n->_vd; diff --git a/lib/nodes/signal_generator.cpp b/lib/nodes/signal_generator.cpp index d1ecd9cc5..d9123da8a 100644 --- a/lib/nodes/signal_generator.cpp +++ b/lib/nodes/signal_generator.cpp @@ -28,6 +28,8 @@ #include #include +using namespace villas::utils; + static enum signal_generator::type signal_generator_lookup_type(const char *type) { if (!strcmp(type, "random")) @@ -331,4 +333,4 @@ __attribute__((destructor(110))) static void deregister_plugin() { if (plugins.state != STATE_DESTROYED) vlist_remove_all(&plugins, &p); -} \ No newline at end of file +} diff --git a/lib/nodes/socket.cpp b/lib/nodes/socket.cpp index 0e0569054..cc7388fb1 100644 --- a/lib/nodes/socket.cpp +++ b/lib/nodes/socket.cpp @@ -48,6 +48,7 @@ static struct plugin p; using namespace villas::node; +using namespace villas::utils; int socket_type_start(villas::node::SuperNode *sn) { diff --git a/lib/nodes/stats.cpp b/lib/nodes/stats.cpp index 8bf7db4ba..d1ee7db6d 100644 --- a/lib/nodes/stats.cpp +++ b/lib/nodes/stats.cpp @@ -33,6 +33,7 @@ #define STATS_METRICS 6 using namespace villas::node; +using namespace villas::utils; static struct vlist *nodes; /** The global list of nodes */ diff --git a/lib/nodes/test_rtt.cpp b/lib/nodes/test_rtt.cpp index e815a1382..f7166e6a8 100644 --- a/lib/nodes/test_rtt.cpp +++ b/lib/nodes/test_rtt.cpp @@ -31,6 +31,8 @@ #include #include +using namespace villas::utils; + static struct plugin p; static int test_rtt_case_start(struct test_rtt *t, int id) diff --git a/lib/nodes/uldaq.cpp b/lib/nodes/uldaq.cpp index 0be8ae906..ae36d331d 100644 --- a/lib/nodes/uldaq.cpp +++ b/lib/nodes/uldaq.cpp @@ -30,6 +30,8 @@ #include #include +using namespace villas::utils; + static unsigned num_devs = ULDAQ_MAX_DEV_COUNT; static DaqDeviceDescriptor descriptors[ULDAQ_MAX_DEV_COUNT]; diff --git a/lib/nodes/websocket.cpp b/lib/nodes/websocket.cpp index 966ed2999..025e688ee 100644 --- a/lib/nodes/websocket.cpp +++ b/lib/nodes/websocket.cpp @@ -37,6 +37,8 @@ #include #include +using namespace villas::utils; + #define DEFAULT_WEBSOCKET_BUFFER_SIZE (1 << 12) /* Private static storage */ diff --git a/lib/nodes/zeromq.cpp b/lib/nodes/zeromq.cpp index c54f45469..f640b7a49 100644 --- a/lib/nodes/zeromq.cpp +++ b/lib/nodes/zeromq.cpp @@ -34,6 +34,8 @@ #include #include +using namespace villas::utils; + static void *context; #if defined(ZMQ_BUILD_DRAFT_API) && ZMQ_MAJOR_VERSION >= 4 && ZMQ_MINOR_VERSION >= 2 && ZMQ_MINOR_VERSION >= 3 diff --git a/lib/path.cpp b/lib/path.cpp index 41b28f220..0963945bf 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -45,6 +45,7 @@ #include using namespace villas; +using namespace villas::utils; static void * path_run_single(void *arg) { diff --git a/lib/sample.cpp b/lib/sample.cpp index 7af8b249e..c75ff03c1 100644 --- a/lib/sample.cpp +++ b/lib/sample.cpp @@ -32,6 +32,8 @@ #include #include +using namespace villas::utils; + int sample_init(struct sample *s) { struct pool *p = sample_pool(s); diff --git a/lib/signal.cpp b/lib/signal.cpp index ee9db3a2e..3e41fb902 100644 --- a/lib/signal.cpp +++ b/lib/signal.cpp @@ -28,6 +28,8 @@ #include #include +using namespace villas::utils; + int signal_init(struct signal *s) { s->enabled = true; diff --git a/lib/socket_addr.cpp b/lib/socket_addr.cpp index 622a67fd1..af293f768 100644 --- a/lib/socket_addr.cpp +++ b/lib/socket_addr.cpp @@ -29,6 +29,8 @@ #include #include +using namespace villas::utils; + char * socket_print_addr(struct sockaddr *saddr) { union sockaddr_union *sa = (union sockaddr_union *) saddr; diff --git a/lib/stats.cpp b/lib/stats.cpp index 7c056a187..3162a9630 100644 --- a/lib/stats.cpp +++ b/lib/stats.cpp @@ -31,6 +31,9 @@ #include #include +using namespace villas; +using namespace villas::utils; + struct stats_metric_description stats_metrics[] = { { "skipped", STATS_METRIC_SMPS_SKIPPED, "samples", "Skipped samples and the distance between them" }, { "reordered", STATS_METRIC_SMPS_REORDERED, "samples", "Reordered samples and the distance between them" }, @@ -94,7 +97,7 @@ int stats_init(struct stats *s, int buckets, int warmup) assert(s->state == STATE_DESTROYED); for (int i = 0; i < STATS_METRIC_COUNT; i++) - hist_init(&s->histograms[i], buckets, warmup); + new (&s->histograms[i]) Hist(buckets, warmup); s->state = STATE_INITIALIZED; @@ -106,7 +109,7 @@ int stats_destroy(struct stats *s) assert(s->state != STATE_DESTROYED); for (int i = 0; i < STATS_METRIC_COUNT; i++) - hist_destroy(&s->histograms[i]); + s->histograms[i].~Hist(); s->state = STATE_DESTROYED; @@ -117,7 +120,7 @@ void stats_update(struct stats *s, enum stats_metric id, double val) { assert(s->state == STATE_INITIALIZED); - hist_put(&s->histograms[id], val); + s->histograms[id].put(val); } json_t * stats_json(struct stats *s) @@ -128,9 +131,9 @@ json_t * stats_json(struct stats *s) for (int i = 0; i < STATS_METRIC_COUNT; i++) { struct stats_metric_description *d = &stats_metrics[i]; - struct hist *h = &s->histograms[i]; + const Hist &h = s->histograms[i]; - json_object_set_new(obj, d->name, hist_json(h)); + json_object_set_new(obj, d->name, h.toJson()); } return obj; @@ -141,11 +144,11 @@ void stats_reset(struct stats *s) assert(s->state == STATE_INITIALIZED); for (int i = 0; i < STATS_METRIC_COUNT; i++) - hist_reset(&s->histograms[i]); + s->histograms[i].reset(); } static std::vector stats_columns = { - { 10, TableColumn::align::LEFT, "Node", "%s" }, + { 10, TableColumn::align::LEFT, "Node", "%s" }, { 10, TableColumn::align::RIGHT, "Recv", "%ju", "pkts" }, { 10, TableColumn::align::RIGHT, "Sent", "%ju", "pkts" }, { 10, TableColumn::align::RIGHT, "Drop", "%ju", "pkts" }, @@ -179,32 +182,32 @@ void stats_print_periodic(struct stats *s, FILE *f, enum stats_format fmt, struc case STATS_FORMAT_HUMAN: stats_table.row(11, node_name_short(n), - (uintmax_t) hist_total(&s->histograms[STATS_METRIC_OWD]), - (uintmax_t) hist_total(&s->histograms[STATS_METRIC_AGE]), - (uintmax_t) hist_total(&s->histograms[STATS_METRIC_SMPS_REORDERED]), - (uintmax_t) hist_total(&s->histograms[STATS_METRIC_SMPS_SKIPPED]), - (double) hist_last(&s->histograms[STATS_METRIC_OWD]), - (double) hist_mean(&s->histograms[STATS_METRIC_OWD]), - (double) 1.0 / hist_last(&s->histograms[STATS_METRIC_GAP_RECEIVED]), - (double) 1.0 / hist_mean(&s->histograms[STATS_METRIC_GAP_RECEIVED]), - (double) hist_mean(&s->histograms[STATS_METRIC_AGE]), - (double) hist_highest(&s->histograms[STATS_METRIC_AGE]) + (uintmax_t) s->histograms[STATS_METRIC_OWD].getTotal(), + (uintmax_t) s->histograms[STATS_METRIC_AGE].getTotal(), + (uintmax_t) s->histograms[STATS_METRIC_SMPS_REORDERED].getTotal(), + (uintmax_t) s->histograms[STATS_METRIC_SMPS_SKIPPED].getTotal(), + (double) s->histograms[STATS_METRIC_OWD].getLast(), + (double) s->histograms[STATS_METRIC_OWD].getMean(), + (double) 1.0 / s->histograms[STATS_METRIC_GAP_RECEIVED].getLast(), + (double) 1.0 / s->histograms[STATS_METRIC_GAP_RECEIVED].getMean(), + (double) s->histograms[STATS_METRIC_AGE].getMean(), + (double) s->histograms[STATS_METRIC_AGE].getHighest() ); break; case STATS_FORMAT_JSON: { json_t *json_stats = json_pack("{ s: s, s: i, s: i, s: i, s: i, s: f, s: f, s: f, s: f, s: f, s: f }", "node", node_name(n), - "recv", hist_total(&s->histograms[STATS_METRIC_OWD]), - "sent", hist_total(&s->histograms[STATS_METRIC_AGE]), - "dropped", hist_total(&s->histograms[STATS_METRIC_SMPS_REORDERED]), - "skipped", hist_total(&s->histograms[STATS_METRIC_SMPS_SKIPPED]), - "owd_last", 1.0 / hist_last(&s->histograms[STATS_METRIC_OWD]), - "owd_mean", 1.0 / hist_mean(&s->histograms[STATS_METRIC_OWD]), - "rate_last", 1.0 / hist_last(&s->histograms[STATS_METRIC_GAP_SAMPLE]), - "rate_mean", 1.0 / hist_mean(&s->histograms[STATS_METRIC_GAP_SAMPLE]), - "age_mean", hist_mean(&s->histograms[STATS_METRIC_AGE]), - "age_max", hist_highest(&s->histograms[STATS_METRIC_AGE]) + "recv", s->histograms[STATS_METRIC_OWD].getTotal(), + "sent", s->histograms[STATS_METRIC_AGE].getTotal(), + "dropped", s->histograms[STATS_METRIC_SMPS_REORDERED].getTotal(), + "skipped", s->histograms[STATS_METRIC_SMPS_SKIPPED].getTotal(), + "owd_last", 1.0 / s->histograms[STATS_METRIC_OWD].getLast(), + "owd_mean", 1.0 / s->histograms[STATS_METRIC_OWD].getMean(), + "rate_last", 1.0 / s->histograms[STATS_METRIC_GAP_SAMPLE].getLast(), + "rate_mean", 1.0 / s->histograms[STATS_METRIC_GAP_SAMPLE].getMean(), + "age_mean", s->histograms[STATS_METRIC_AGE].getMean(), + "age_max", s->histograms[STATS_METRIC_AGE].getHighest() ); json_dumpf(json_stats, f, 0); break; @@ -224,7 +227,7 @@ void stats_print(struct stats *s, FILE *f, enum stats_format fmt, int verbose) struct stats_metric_description *d = &stats_metrics[i]; info("%s: %s", d->name, d->desc); - hist_print(&s->histograms[i], verbose); + s->histograms[i].print(verbose); } break; @@ -243,36 +246,36 @@ union signal_data stats_get_value(const struct stats *s, enum stats_metric sm, e { assert(s->state == STATE_INITIALIZED); - const struct hist *h = &s->histograms[sm]; + const Hist &h = s->histograms[sm]; union signal_data d; switch (st) { case STATS_TYPE_TOTAL: - d.i = h->total; + d.i = h.getTotal(); break; case STATS_TYPE_LAST: - d.f = h->last; + d.f = h.getLast(); break; case STATS_TYPE_HIGHEST: - d.f = h->highest; + d.f = h.getHighest(); break; case STATS_TYPE_LOWEST: - d.f = h->lowest; + d.f = h.getLowest(); break; case STATS_TYPE_MEAN: - d.f = hist_mean(h); + d.f = h.getMean(); break; case STATS_TYPE_STDDEV: - d.f = hist_stddev(h); + d.f = h.getStddev(); break; case STATS_TYPE_VAR: - d.f = hist_var(h); + d.f = h.getVar(); break; default: diff --git a/lib/super_node.cpp b/lib/super_node.cpp index 857439b1a..918ba2131 100644 --- a/lib/super_node.cpp +++ b/lib/super_node.cpp @@ -44,6 +44,7 @@ using namespace villas; using namespace villas::node; +using namespace villas::utils; SuperNode::SuperNode() : state(STATE_INITIALIZED), diff --git a/src/villas-test-rtt.cpp b/src/villas-test-rtt.cpp index d848eab74..05f339973 100644 --- a/src/villas-test-rtt.cpp +++ b/src/villas-test-rtt.cpp @@ -168,7 +168,7 @@ check: if (optarg == endptr) { int ret; - struct hist hist; + Hist hist(hist_buckets, hist_warmup); struct timespec send, recv; struct sample *smp_send = (struct sample *) new char[SAMPLE_LENGTH(2)]; @@ -197,10 +197,6 @@ check: if (optarg == endptr) if (ret) throw RuntimeError("Failed to start node {}: reason={}", node_name(node), ret); - ret = hist_init(&hist, hist_buckets, hist_warmup); - if (ret) - throw RuntimeError("Failed to initialize histogram"); - /* Print header */ fprintf(stdout, "%17s%5s%10s%10s%10s%10s%10s\n", "timestamp", "seq", "rtt", "min", "max", "mean", "stddev"); @@ -222,30 +218,26 @@ check: if (optarg == endptr) if (rtt < 0) logger->warn("Negative RTT: {}", rtt); - hist_put(&hist, rtt); + hist.put(rtt); smp_send->sequence++; fprintf(stdout, "%10lu.%06lu%5" PRIu64 "%10.3f%10.3f%10.3f%10.3f%10.3f\n", recv.tv_sec, recv.tv_nsec / 1000, smp_send->sequence, - 1e3 * rtt, 1e3 * hist.lowest, 1e3 * hist.highest, - 1e3 * hist_mean(&hist), 1e3 * hist_stddev(&hist)); + 1e3 * rtt, 1e3 * hist.getLowest(), 1e3 * hist.getHighest(), + 1e3 * hist.getMean(), 1e3 * hist.getStddev()); } struct stat st; if (!fstat(fd, &st)) { FILE *f = fdopen(fd, "w"); - hist_dump_matlab(&hist, f); + hist.dumpMatlab(f); fclose(f); } else throw RuntimeError("Invalid file descriptor: {}", fd); - hist_print(&hist, 1); - - ret = hist_destroy(&hist); - if (ret) - throw RuntimeError("Failed to destroy histogram"); + hist.print(true); ret = node_stop(node); if (ret)