blob: eaaded54d0e77336d28929b2702d07272eef4039 [file] [log] [blame]
Keith Davis02356de2019-08-26 18:28:17 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "ProfilingService.hpp"
7
8namespace armnn
9{
10
11namespace profiling
12{
13
14ProfilingService::ProfilingService(const Runtime::CreationOptions::ExternalProfilingOptions& options)
15 : m_Options(options)
16{
17 Initialise();
18}
19
20void ProfilingService::Initialise()
21{
22 if (m_Options.m_EnableProfiling == true)
23 {
24 // Setup Counter Directory - this should only be created if profiling is enabled
25 // Setup Counter meta
26
27 // For now until CounterDirectory setup is implemented, change m_State once everything initialised
28 m_State.TransitionToState(ProfilingState::NotConnected);
29 }
30}
31
32void ProfilingService::Run()
33{
34 if (m_State.GetCurrentState() == ProfilingState::NotConnected)
35 {
36 // Since GetProfilingConnection is not implemented, if !NULL,
37 // then change to WaitingForAck. This will need to change once there is implementation
38 // for the IProfilingConnection
39 if (!m_Factory.GetProfilingConnection(m_Options))
40 {
41 m_State.TransitionToState(ProfilingState::WaitingForAck);
42 }
43 } else if (m_State.GetCurrentState() == ProfilingState::Uninitialised && m_Options.m_EnableProfiling == true)
44 {
45 Initialise();
46 }
47}
48
49ProfilingState ProfilingService::GetCurrentState() const
50{
51 return m_State.GetCurrentState();
52}
53} // namespace profiling
54
55} // namespace armnn