| 110 | } |
| 111 | |
| 112 | void ProfilingService::Update() |
| 113 | { |
| 114 | #if !defined(ARMNN_STUB_PROFILING) |
| 115 | if (!m_Options.m_EnableProfiling) |
| 116 | { |
| 117 | // Don't run if profiling is disabled |
| 118 | return; |
| 119 | } |
| 120 | |
| 121 | ProfilingState currentState = m_StateMachine.GetCurrentState(); |
| 122 | switch (currentState) |
| 123 | { |
| 124 | case ProfilingState::Uninitialised: |
| 125 | |
| 126 | // Initialize the profiling service |
| 127 | Initialize(); |
| 128 | |
| 129 | // Move to the next state |
| 130 | m_StateMachine.TransitionToState(ProfilingState::NotConnected); |
| 131 | break; |
| 132 | case ProfilingState::NotConnected: |
| 133 | // Stop the command thread (if running) |
| 134 | m_CommandHandler.Stop(); |
| 135 | |
| 136 | // Stop the send thread (if running) |
| 137 | m_SendThread.Stop(false); |
| 138 | |
| 139 | // Stop the periodic counter capture thread (if running) |
| 140 | m_PeriodicCounterCapture.Stop(); |
| 141 | |
| 142 | // Reset any existing profiling connection |
| 143 | m_ProfilingConnection.reset(); |
| 144 | |
| 145 | try |
| 146 | { |
| 147 | // Setup the profiling connection |
| 148 | ARM_PIPE_ASSERT(m_ProfilingConnectionFactory); |
| 149 | m_ProfilingConnection = m_ProfilingConnectionFactory->GetProfilingConnection(m_Options); |
| 150 | } |
| 151 | catch (const arm::pipe::ProfilingException& e) |
| 152 | { |
| 153 | ARM_PIPE_LOG(warning) << "An error has occurred when creating the profiling connection: " |
| 154 | << e.what(); |
| 155 | } |
| 156 | catch (const arm::pipe::SocketConnectionException& e) |
| 157 | { |
| 158 | ARM_PIPE_LOG(warning) << "An error has occurred when creating the profiling connection [" |
| 159 | << e.what() << "] on socket [" << e.GetSocketFd() << "]."; |
| 160 | } |
| 161 | |
| 162 | // Move to the next state |
| 163 | m_StateMachine.TransitionToState(m_ProfilingConnection |
| 164 | ? ProfilingState::WaitingForAck // Profiling connection obtained, wait for ack |
| 165 | : ProfilingState::NotConnected); // Profiling connection failed, stay in the |
| 166 | // "NotConnected" state |
| 167 | break; |
| 168 | case ProfilingState::WaitingForAck: |
| 169 | ARM_PIPE_ASSERT(m_ProfilingConnection); |
nothing calls this directly
no test coverage detected