ArmNN
 21.02
IProfiler.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <iostream>
9 #include <memory>
10 #include <vector>
11 
12 namespace armnn
13 {
14 
15 class ProfilerImpl;
16 class BackendId;
17 class Instrument;
18 class Event;
19 class IProfiler
20 {
21 public:
22  /// Enables/disables profiling for this profiler.
23  /// @param [in] enableProfiling A flag that indicates whether profiling should be enabled or not.
24  void EnableProfiling(bool enableProfiling);
25 
26  /// Checks whether profiling is enabled.
27  /// Profiling is disabled by default.
28  /// @return true if profiling is enabled, false otherwise.
29  bool IsProfilingEnabled();
30 
31  /// Analyzes the tracked events and writes the results to the given output stream.
32  /// Please refer to the configuration variables in Profiling.cpp to customize the information written.
33  /// @param [out] outStream The stream where to write the profiling results to.
34  void AnalyzeEventsAndWriteResults(std::ostream& outStream) const;
35 
36  /// Print stats for events in JSON Format to the given output stream.
37  /// @param [out] outStream The stream where to write the profiling results to.
38  void Print(std::ostream& outStream) const;
39 
40  ~IProfiler();
41  IProfiler();
42 
43 private:
44  using InstrumentPtr = std::unique_ptr<Instrument>;
45  Event* BeginEvent(const BackendId& backendId,
46  const std::string& label,
47  std::vector<InstrumentPtr>&& instruments);
48  std::unique_ptr<ProfilerImpl> pProfilerImpl;
49  friend class ScopedProfilingEvent;
50 
51  // Friend functions for unit testing, see ProfilerTests.cpp.
52  friend size_t GetProfilerEventSequenceSize(armnn::IProfiler* profiler);
53 };
54 
55 } // namespace armnn
Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when Ev...
friend size_t GetProfilerEventSequenceSize(armnn::IProfiler *profiler)
void Print(std::ostream &outStream) const
Print stats for events in JSON Format to the given output stream.
Definition: Profiling.cpp:522
void AnalyzeEventsAndWriteResults(std::ostream &outStream) const
Analyzes the tracked events and writes the results to the given output stream.
Definition: Profiling.cpp:517
Copyright (c) 2021 ARM Limited and Contributors.
void EnableProfiling(bool enableProfiling)
Enables/disables profiling for this profiler.
Definition: Profiling.cpp:507
bool IsProfilingEnabled()
Checks whether profiling is enabled.
Definition: Profiling.cpp:512