aboutsummaryrefslogtreecommitdiff
path: root/projects/hsm
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2017-05-03 16:38:09 -0400
committerPaul Selkirk <paul@psgd.org>2017-05-03 16:38:09 -0400
commit7ef51e89d5a1d7d75cb0b8d3832327beb46319dd (patch)
tree1024e1add5490394bf5747ab30ab528d51ca472c /projects/hsm
parent1175ff63f2a8c4762692551403862f9f0789aef8 (diff)
Add some task metrics.
Diffstat (limited to 'projects/hsm')
-rw-r--r--projects/hsm/Makefile2
-rw-r--r--projects/hsm/mgmt-task.c34
2 files changed, 35 insertions, 1 deletions
diff --git a/projects/hsm/Makefile b/projects/hsm/Makefile
index 927c9f1..ecd1a5d 100644
--- a/projects/hsm/Makefile
+++ b/projects/hsm/Makefile
@@ -13,6 +13,8 @@ OBJS = mgmt-cli.o \
BOARD_OBJS += $(TOPLEVEL)/task.o
+CFLAGS += -DTASK_METRICS
+
CFLAGS += -DNUM_RPC_TASK=4
CFLAGS += -I$(LIBHAL_SRC)
diff --git a/projects/hsm/mgmt-task.c b/projects/hsm/mgmt-task.c
index a1ae7e6..12ce2b8 100644
--- a/projects/hsm/mgmt-task.c
+++ b/projects/hsm/mgmt-task.c
@@ -69,10 +69,42 @@ static int cmd_task_show(struct cli_def *cli, const char *command, char *argv[],
return CLI_OK;
}
+#ifdef TASK_METRICS
+static int cmd_task_show_metrics(struct cli_def *cli, const char *command, char *argv[], int argc)
+{
+ struct task_metrics tm;
+
+ task_get_metrics(&tm);
+
+ cli_print(cli, "avg time between yields: %ld.%06ld sec", tm.avg.tv_sec, tm.avg.tv_usec);
+ cli_print(cli, "max time between yields: %ld.%06ld sec", tm.max.tv_sec, tm.max.tv_usec);
+
+ return CLI_OK;
+}
+
+static int cmd_task_reset_metrics(struct cli_def *cli, const char *command, char *argv[], int argc)
+{
+ task_reset_metrics();
+
+ return CLI_OK;
+}
+#endif
+
void configure_cli_task(struct cli_def *cli)
{
struct cli_command *c = cli_register_command(cli, NULL, "task", NULL, 0, 0, NULL);
/* task show */
- cli_register_command(cli, c, "show", cmd_task_show, 0, 0, "Show the active tasks");
+ struct cli_command *c_show = cli_register_command(cli, c, "show", cmd_task_show, 0, 0, "Show the active tasks");
+
+#ifdef TASK_METRICS
+ /* task show metrics */
+ cli_register_command(cli, c_show, "metrics", cmd_task_show_metrics, 0, 0, "Show task metrics");
+
+ /* task reset */
+ struct cli_command *c_reset = cli_register_command(cli, c, "reset", NULL, 0, 0, NULL);
+
+ /* task reset metrics */
+ cli_register_command(cli, c_reset, "metrics", cmd_task_reset_metrics, 0, 0, "Reset task metrics");
+#endif
}