aboutsummaryrefslogtreecommitdiff
path: root/projects/hsm/mgmt-task.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2018-04-06 16:14:43 -0400
committerPaul Selkirk <paul@psgd.org>2018-04-06 22:34:05 -0400
commit6c7bd80b4e7bc5af1659b14b7fb0038f3dc53989 (patch)
treea10451c611dcf9f7d31a019c6bbc2e81fc8cd9ac /projects/hsm/mgmt-task.c
parentb35b87ea14016760786319a23b87792f1e1041de (diff)
parentf508e24f5b872a8f7d642eb4fb2217dd1497de96 (diff)
Merge branch 'profiling'
Diffstat (limited to 'projects/hsm/mgmt-task.c')
-rw-r--r--projects/hsm/mgmt-task.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/projects/hsm/mgmt-task.c b/projects/hsm/mgmt-task.c
index beffc32..c2a3d3f 100644
--- a/projects/hsm/mgmt-task.c
+++ b/projects/hsm/mgmt-task.c
@@ -77,10 +77,54 @@ static int cmd_task_show(struct cli_def *cli, const char *command, char *argv[],
return CLI_OK;
}
+#ifdef DO_TASK_METRICS
+static int cmd_task_show_metrics(struct cli_def *cli, const char *command, char *argv[], int argc)
+{
+ command = command;
+ argv = argv;
+ argc = 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)
+{
+ cli = cli;
+ command = command;
+ argv = argv;
+ argc = 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 */
+#ifdef DO_TASK_METRICS
+ struct cli_command *c_show =
+#endif
cli_register_command(cli, c, "show", cmd_task_show, 0, 0, "Show the active tasks");
+
+#ifdef DO_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
}