clDNN
profiling.hpp
1 /*
2 // Copyright (c) 2016 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 
17 #pragma once
18 #include "cldnn_defs.h"
19 #include <chrono>
20 #include <memory>
21 #include <vector>
22 
23 namespace cldnn {
24 namespace instrumentation
25 {
28 
31 
33 template<class ClockTy = std::chrono::steady_clock>
34 class timer {
35  typename ClockTy::time_point start_point;
36 public:
38  typedef typename ClockTy::duration val_type;
39 
41  timer() :start_point(ClockTy::now()) {}
42 
44  val_type uptime() const { return ClockTy::now() - start_point; }
45 };
46 
49 {
51  virtual std::chrono::nanoseconds value() const = 0;
53  virtual ~profiling_period() = default;
54 };
55 
58 {
60  template<class _Rep, class _Period>
61  profiling_period_basic(const std::chrono::duration<_Rep, _Period>& val) :
62  _value(std::chrono::duration_cast<std::chrono::nanoseconds>(val)) {}
63 
65  std::chrono::nanoseconds value() const override { return _value; }
66 private:
67  std::chrono::nanoseconds _value;
68 };
69 
73  std::string name;
74  std::shared_ptr<profiling_period> value;
75 };
76 
79  std::string name;
80  std::vector<profiling_interval> intervals;
81 };
84 }}
virtual ~profiling_period()=default
Destructor.
val_type uptime() const
Returns time eapsed since construction.
Definition: profiling.hpp:44
virtual std::chrono::nanoseconds value() const =0
Returns profiling period value.
Basic profiling_period implementation which stores data as an simple period value.
Definition: profiling.hpp:57
std::vector< profiling_interval > intervals
List of intervals.
Definition: profiling.hpp:80
std::shared_ptr< profiling_period > value
Interval value.
Definition: profiling.hpp:74
ClockTy::duration val_type
Timer value type.
Definition: profiling.hpp:38
Represents list of profiling_interval.
Definition: profiling.hpp:78
std::string name
Display name.
Definition: profiling.hpp:79
Abstract class to represent profiling period.
Definition: profiling.hpp:48
profiling_period_basic(const std::chrono::duration< _Rep, _Period > &val)
Constructs from std::chrono::duration.
Definition: profiling.hpp:61
Represents prifiling interval as its name and value.
Definition: profiling.hpp:72
Helper class to calculate time periods.
Definition: profiling.hpp:34
std::chrono::nanoseconds value() const override
Returns profiling period value passed in constructor.
Definition: profiling.hpp:65