MLECO-1870: Cherry pick profiling changes from dev to open source repo
* Documentation update

Change-Id: If85e7ebc44498840b291c408f14e66a5a5faa424
Signed-off-by: Isabella Gottardi <isabella.gottardi@arm.com>
diff --git a/source/use_case/asr/src/UseCaseHandler.cc b/source/use_case/asr/src/UseCaseHandler.cc
index e706eb8..5d3157a 100644
--- a/source/use_case/asr/src/UseCaseHandler.cc
+++ b/source/use_case/asr/src/UseCaseHandler.cc
@@ -67,6 +67,8 @@
         auto& platform = ctx.Get<hal_platform&>("platform");
         platform.data_psn->clear(COLOR_BLACK);
 
+        auto& profiler = ctx.Get<Profiler&>("profiler");
+
         /* If the request has a valid size, set the audio index. */
         if (clipIndex < NUMBER_OF_FILES) {
             if (!_SetAppCtxClipIdx(ctx, clipIndex)) {
@@ -168,18 +170,11 @@
                 info("Inference %zu/%zu\n", audioDataSlider.Index() + 1,
                      static_cast<size_t>(ceilf(audioDataSlider.FractionalTotalStrides() + 1)));
 
-                Profiler prepProfiler{&platform, "pre-processing"};
-                prepProfiler.StartProfiling();
-
                 /* Calculate MFCCs, deltas and populate the input tensor. */
                 prep.Invoke(inferenceWindow, inferenceWindowLen, inputTensor);
 
-                prepProfiler.StopProfiling();
-                std::string prepProfileResults = prepProfiler.GetResultsAndReset();
-                info("%s\n", prepProfileResults.c_str());
-
                 /* Run inference over this audio clip sliding window. */
-                arm::app::RunInference(platform, model);
+                arm::app::RunInference(model, profiler);
 
                 /* Post-process. */
                 postp.Invoke(outputTensor, reductionAxis, !audioDataSlider.HasNext());
@@ -216,6 +211,8 @@
                 return false;
             }
 
+            profiler.PrintProfilingResult();
+
             _IncrementAppCtxClipIdx(ctx);
 
         } while (runAll && ctx.Get<uint32_t>("clipIndex") != startClipIdx);
@@ -256,6 +253,8 @@
 
         platform.data_psn->set_text_color(COLOR_GREEN);
 
+        info("Final results:\n");
+        info("Total number of inferences: %zu\n", results.size());
         /* Results from multiple inferences should be combined before processing. */
         std::vector<arm::app::ClassificationResult> combinedResults;
         for (auto& result : results) {
@@ -268,8 +267,9 @@
         for (const auto & result : results) {
             std::string infResultStr = audio::asr::DecodeOutput(result.m_resultVec);
 
-            info("Result for inf %u: %s\n", result.m_inferenceNumber,
-                                            infResultStr.c_str());
+            info("For timestamp: %f (inference #: %u); label: %s\n",
+                 result.m_timeStamp, result.m_inferenceNumber,
+                 infResultStr.c_str());
         }
 
         /* Get the decoded result for the combined result. */
@@ -280,7 +280,7 @@
                             dataPsnTxtStartX1, dataPsnTxtStartY1,
                             allow_multiple_lines);
 
-        info("Final result: %s\n", finalResultStr.c_str());
+        info("Complete recognition: %s\n", finalResultStr.c_str());
         return true;
     }