ArmNN
 24.08
Instrument.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 <string>
9 #include <vector>
10 
11 namespace armnn
12 {
13 
15 {
16  enum Unit
17  {
21  };
22 
23  inline static const char* ToString(Unit unit)
24  {
25  switch (unit)
26  {
27  case TIME_NS: return "ns";
28  case TIME_US: return "us";
29  case TIME_MS: return "ms";
30  default: return "";
31  }
32  }
33 
34  Measurement(const std::string& name, double value, Unit unit)
35  : m_Name(name)
36  , m_Value(value)
37  , m_Unit(unit)
38  {}
39  Measurement(const Measurement&) = default;
40  ~Measurement() = default;
41 
42  std::string m_Name;
43  double m_Value;
45 
46 private:
47  // please don't default construct, otherwise Units will be wrong
48  Measurement() = delete;
49 };
50 
52 {
53 public:
54  virtual ~Instrument() {}
55 
56  virtual void Start() = 0;
57 
58  virtual void Stop() = 0;
59 
60  virtual std::vector<Measurement> GetMeasurements() const = 0;
61 
62  virtual const char* GetName() const = 0;
63 
64  virtual bool HasKernelMeasurements() const { return false;}
65 
66 };
67 
68 } //namespace armnn
armnn::Measurement::m_Value
double m_Value
Definition: Instrument.hpp:43
armnn::Instrument::~Instrument
virtual ~Instrument()
Definition: Instrument.hpp:54
armnn::Measurement::TIME_MS
@ TIME_MS
Definition: Instrument.hpp:20
armnn::Measurement::m_Unit
Unit m_Unit
Definition: Instrument.hpp:44
armnn::Instrument::HasKernelMeasurements
virtual bool HasKernelMeasurements() const
Definition: Instrument.hpp:64
armnn::Measurement::TIME_NS
@ TIME_NS
Definition: Instrument.hpp:18
armnn::Instrument::Start
virtual void Start()=0
armnn::Measurement::Measurement
Measurement(const std::string &name, double value, Unit unit)
Definition: Instrument.hpp:34
armnn::Measurement::TIME_US
@ TIME_US
Definition: Instrument.hpp:19
armnn::Instrument::GetMeasurements
virtual std::vector< Measurement > GetMeasurements() const =0
armnn::Measurement::~Measurement
~Measurement()=default
armnn::Instrument::Stop
virtual void Stop()=0
armnn::Measurement::m_Name
std::string m_Name
Definition: Instrument.hpp:42
armnn::Measurement::ToString
static const char * ToString(Unit unit)
Definition: Instrument.hpp:23
armnn::Measurement
Definition: Instrument.hpp:14
armnn::Instrument
Definition: Instrument.hpp:51
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::Measurement::Unit
Unit
Definition: Instrument.hpp:16
armnn::Instrument::GetName
virtual const char * GetName() const =0