You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by na...@apache.org on 2020/12/03 19:50:27 UTC

[mynewt-mcumgr] 01/01: Track time taken for walking logs

This is an automated email from the ASF dual-hosted git repository.

naveenkaje pushed a commit to branch track_time
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git

commit df6c67194b3c528b202303d8849fb9d1978dfdf4
Author: Naveen Kaje <na...@juul.com>
AuthorDate: Thu Dec 3 13:47:35 2020 -0600

    Track time taken for walking logs
---
 cmd/log_mgmt/src/log_mgmt.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/cmd/log_mgmt/src/log_mgmt.c b/cmd/log_mgmt/src/log_mgmt.c
index 9f24b72..f369f5b 100644
--- a/cmd/log_mgmt/src/log_mgmt.c
+++ b/cmd/log_mgmt/src/log_mgmt.c
@@ -27,6 +27,7 @@
 #include "log_mgmt/log_mgmt_impl.h"
 #include "log_mgmt/log_mgmt_config.h"
 #include "log/log.h"
+#include "console/console.h"
 
 /* Log mgmt encoder context used for multiple calls of the
  * entry encode function since the function gets called twice,
@@ -382,6 +383,9 @@ log_mgmt_show(struct mgmt_ctxt *ctxt)
         },
     };
 
+    uint32_t ms;
+    os_time_t t = os_time_get();
+
     name[0] = '\0';
     rc = cbor_read_object(&ctxt->it, attr);
     if (rc != 0) {
@@ -427,6 +431,7 @@ log_mgmt_show(struct mgmt_ctxt *ctxt)
         /* Stream logs cannot be read. */
         if (log.type != LOG_MGMT_TYPE_STREAM) {
             if (name_len == 0 || strcmp(name, log.name) == 0) {
+                console_printf("log encode name %s, index %lld\n", log.name, index);
                 rc = log_encode(&log, &logs, timestamp, index);
                 if (rc) {
                     goto err;
@@ -451,6 +456,9 @@ err:
         return LOG_MGMT_ERR_ENOMEM;
     }
 
+    t = os_time_get() - t;
+    os_time_ticks_to_ms(t, &ms);
+    console_printf("log mgmt show %"PRIu32"\n", ms);
     return 0;
 }