Purge underscored header file barriers
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / common / frame-time-stats.h
1 #ifndef DALI_INTERNAL_ADAPTOR_FRAME_TIME_STATS_H
2 #define DALI_INTERNAL_ADAPTOR_FRAME_TIME_STATS_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/system/common/frame-time-stamp.h>
23 #include <dali/public-api/common/dali-vector.h>
24
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace Adaptor
33 {
34
35 /**
36  * Used to get statistics about time stamps over a period of time.
37  * E.g. the min, max, total and average time spent inside two markers,
38  * such as UPDATE_START and UPDATE_END
39  */
40 struct FrameTimeStats
41 {
42   /**
43    * Constructor
44    */
45   FrameTimeStats();
46
47   /**
48    * Destructor, not intended as a base class
49    */
50   ~FrameTimeStats();
51
52   /**
53    * Timer start time
54    * @param timeStamp time stamp
55    */
56    void StartTime( const FrameTimeStamp& timeStamp );
57
58    /**
59     * Timer end time
60     * @param timeStamp time stamp
61     */
62    void EndTime( const FrameTimeStamp& timeStamp );
63
64    /**
65     * Reset all internal counters / state except total time.
66     */
67    void Reset();
68
69    /**
70     * @return maximum time in seconds
71     */
72    float GetMaxTime() const;
73
74    /**
75     * @return minimum time in seconds
76     */
77    float GetMinTime() const;
78
79    /**
80     * @return total time in second
81     */
82    float GetTotalTime() const;
83
84    /**
85     * Get how many times the timer has been started /stopped
86     */
87    unsigned int GetRunCount() const;
88
89    /**
90     * Calculate the mean and standard deviation
91     *
92     * @param[out] mean The return mean value
93     * @param[out] standardDeviation The return standard deviation value
94     */
95    void CalculateMean( float& meanOut, float& standardDeviationOut ) const;
96
97 private:
98
99    /**
100     * internal time state.
101     */
102    enum TimeState
103    {
104      WAITING_FOR_START_TIME,    ///< waiting for start time marker
105      WAITING_FOR_END_TIME       ///< waiting for end time marker
106    };
107
108    typedef Dali::Vector< unsigned int > Samples;
109    Samples mSamples;
110
111    unsigned int mMin;                  ///< current minimum value in microseconds
112    unsigned int mMax;                  ///< current maximum value in microseconds
113    unsigned int mTotal;                ///< current total in in microseconds
114    unsigned int mRunCount;      ///< how many times the timer has been start / stopped
115    FrameTimeStamp mStart;       ///< start time stamp, to calculate the diff
116    TimeState mTimeState:1;      ///< time state
117    bool mMinMaxTimeSet:1;       ///< whether the min-max values have been configured
118
119 };
120
121 } // namespace Adaptor
122
123 } // namespace Internal
124
125 } // namespace Dali
126
127 #endif // DALI_INTERNAL_ADAPTOR_FRAME_TIME_STATS_H
128