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/kws_asr/src/UseCaseHandler.cc b/source/use_case/kws_asr/src/UseCaseHandler.cc
index c50796f..a428210 100644
--- a/source/use_case/kws_asr/src/UseCaseHandler.cc
+++ b/source/use_case/kws_asr/src/UseCaseHandler.cc
@@ -127,6 +127,7 @@
 
         KWSOutput output;
 
+        auto& profiler = ctx.Get<Profiler&>("profiler");
         auto& kwsModel = ctx.Get<Model&>("kwsmodel");
         if (!kwsModel.IsInited()) {
             printf_err("KWS model has not been initialised\n");
@@ -243,7 +244,7 @@
                  audioDataSlider.TotalStrides() + 1);
 
             /* Run inference over this audio clip sliding window. */
-            arm::app::RunInference(platform, kwsModel);
+            arm::app::RunInference(kwsModel, profiler);
 
             std::vector<ClassificationResult> kwsClassificationResult;
             auto& kwsClassifier = ctx.Get<KwsClassifier&>("kwsclassifier");
@@ -284,6 +285,8 @@
             return output;
         }
 
+        profiler.PrintProfilingResult();
+
         output.executionSuccess = true;
         return output;
     }
@@ -300,6 +303,7 @@
         constexpr uint32_t dataPsnTxtInfStartX = 20;
         constexpr uint32_t dataPsnTxtInfStartY = 40;
 
+        auto& profiler = ctx.Get<Profiler&>("profiler");
         auto& platform = ctx.Get<hal_platform&>("platform");
         platform.data_psn->clear(COLOR_BLACK);
 
@@ -389,18 +393,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. */
             asrPrep.Invoke(asrInferenceWindow, asrInferenceWindowLen, asrInputTensor);
 
-            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, asrModel);
+            arm::app::RunInference(asrModel, profiler);
 
             /* Post-process. */
             asrPostp.Invoke(asrOutputTensor, reductionAxis, !audioDataSlider.HasNext());
@@ -432,6 +429,8 @@
             return false;
         }
 
+        profiler.PrintProfilingResult();
+
         return true;
     }