IVGCVSW-8298 Fix failing fsrcnn test

Change-Id: I03c26ab763ec306a6efe31f9b4e0b1c058589bf7
Signed-off-by: Nikhil Raj <nikhil.raj@arm.com>
diff --git a/delegate/classic/src/armnn_delegate.cpp b/delegate/classic/src/armnn_delegate.cpp
index ed63215..c3815b6 100644
--- a/delegate/classic/src/armnn_delegate.cpp
+++ b/delegate/classic/src/armnn_delegate.cpp
@@ -276,14 +276,14 @@
 
 ArmnnSubgraph::~ArmnnSubgraph()
 {
-    // We're finished with the network.
-    m_Runtime->UnloadNetwork(m_NetworkId);
-    // The delegate holds its own Arm NN runtime so this is our last chance to print internal profiling data.
     std::shared_ptr<armnn::IProfiler> profiler = m_Runtime->GetProfiler(m_NetworkId);
     if (profiler && profiler->IsProfilingEnabled())
     {
         profiler->Print(std::cout);
     }
+
+    // We're finished with the network.
+    m_Runtime->UnloadNetwork(m_NetworkId);
 }
 
 TfLiteStatus ArmnnSubgraph::AddInputLayer(DelegateData& delegateData,
diff --git a/src/armnn/Profiling.cpp b/src/armnn/Profiling.cpp
index 78afb05..c221106 100644
--- a/src/armnn/Profiling.cpp
+++ b/src/armnn/Profiling.cpp
@@ -486,12 +486,7 @@
     outStream.flags(oldFlags);
     outStream.precision(oldPrecision);
 
-    if (m_DetailsToStdOutMethod == ProfilingDetailsMethod::DetailsOnly)
-    {
-        exit(0);
-    }
 }
-
 void ProfilerImpl::AnalyzeEventsAndWriteResults(std::ostream& outStream) const
 {
     // Stack should be empty now.
diff --git a/tests/ExecuteNetwork/ArmNNExecutor.cpp b/tests/ExecuteNetwork/ArmNNExecutor.cpp
index 7060497..4518f14 100644
--- a/tests/ExecuteNetwork/ArmNNExecutor.cpp
+++ b/tests/ExecuteNetwork/ArmNNExecutor.cpp
@@ -91,7 +91,12 @@
 
 ArmNNExecutor::~ArmNNExecutor()
 {
-    m_Runtime->UnloadNetwork(m_NetworkId);
+    std::shared_ptr<armnn::IProfiler> profiler = m_Runtime->GetProfiler(m_NetworkId);
+    // If profiling is enabled print out the results
+    if (profiler && profiler->IsProfilingEnabled())
+    {
+        profiler->Print(std::cout);
+    }
 }
 
 void ArmNNExecutor::ExecuteAsync()
@@ -194,12 +199,6 @@
 
         const auto inferenceDuration = armnn::GetTimeDuration(start_time);
 
-        // If profiling is enabled print out the results
-        if(profiler && profiler->IsProfilingEnabled() && x == (m_Params.m_Iterations - 1))
-        {
-            profiler->Print(std::cout);
-        }
-
         if(ret == armnn::Status::Failure)
         {
             throw armnn::Exception("IRuntime::EnqueueWorkload failed");
diff --git a/tests/ExecuteNetwork/ExecuteNetwork.cpp b/tests/ExecuteNetwork/ExecuteNetwork.cpp
index 9f81eb1..8727fc6 100644
--- a/tests/ExecuteNetwork/ExecuteNetwork.cpp
+++ b/tests/ExecuteNetwork/ExecuteNetwork.cpp
@@ -1,5 +1,5 @@
 //
-// Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2022-2024 Arm Ltd and Contributors. All rights reserved.
 // SPDX-License-Identifier: MIT
 //
 
@@ -93,6 +93,11 @@
         }
 
         comparisonExecutor->PrintNetworkInfo();
+
+        if (programOptions.m_ExNetParams.m_OutputDetailsOnlyToStdOut)
+        {
+            return EXIT_SUCCESS;
+        }
         comparisonExecutor->Execute();
 
         comparisonExecutor->CompareAndPrintResult(outputResults);