LCOV - code coverage report
Current view: top level - gfx/layers/composite - Diagnostics.h (source / functions) Hit Total Coverage
Test: output.info Lines: 6 34 17.6 %
Date: 2017-07-14 16:53:18 Functions: 3 14 21.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef mozilla_gfx_layers_composite_Diagnostics_h
       7             : #define mozilla_gfx_layers_composite_Diagnostics_h
       8             : 
       9             : #include "FPSCounter.h"
      10             : #include "gfxPrefs.h"
      11             : #include "mozilla/Maybe.h"
      12             : #include "mozilla/TimeStamp.h"
      13             : #include <deque>
      14             : #include <string>
      15             : #include <utility>
      16             : 
      17             : namespace mozilla {
      18             : namespace layers {
      19             : 
      20             : class PaintTiming;
      21             : 
      22           9 : class TimedMetric
      23             : {
      24             :   typedef std::pair<float, TimeStamp> Entry;
      25             : 
      26             : public:
      27           0 :   void Add(float aValue) {
      28           0 :     if (mHistory.size() > kMaxHistory) {
      29           0 :       mHistory.pop_front();
      30             :     }
      31           0 :     mHistory.push_back(Entry(aValue, TimeStamp::Now()));
      32           0 :   }
      33             : 
      34             :   float Average() const;
      35           0 :   bool Empty() const {
      36           0 :     return mHistory.empty();
      37             :   }
      38             : 
      39             : private:
      40             :   static const size_t kMaxHistory = 60;
      41             : 
      42             :   std::deque<Entry> mHistory;
      43             : };
      44             : 
      45             : // These statistics are collected by layers backends, preferably by the GPU
      46           0 : struct GPUStats
      47             : {
      48           0 :   GPUStats()
      49           0 :    : mInvalidPixels(0),
      50             :      mScreenPixels(0),
      51           0 :      mPixelsFilled(0)
      52           0 :   {}
      53             : 
      54             :   uint32_t mInvalidPixels;
      55             :   uint32_t mScreenPixels;
      56             :   uint32_t mPixelsFilled;
      57             :   Maybe<float> mDrawTime;
      58             : };
      59             : 
      60             : // Collects various diagnostics about layers performance.
      61           0 : class Diagnostics
      62             : {
      63             : public:
      64             :   Diagnostics();
      65             : 
      66             :   void RecordPaintTimes(const PaintTiming& aPaintTimes);
      67           0 :   void RecordUpdateTime(float aValue) {
      68           0 :     mUpdateMs.Add(aValue);
      69           0 :   }
      70           0 :   void RecordPrepareTime(float aValue) {
      71           0 :     mPrepareMs.Add(aValue);
      72           0 :   }
      73           0 :   void RecordCompositeTime(float aValue) {
      74           0 :     mCompositeMs.Add(aValue);
      75           0 :   }
      76           0 :   void AddTxnFrame() {
      77           0 :     mTransactionFps.AddFrame(TimeStamp::Now());
      78           0 :   }
      79             : 
      80             :   std::string GetFrameOverlayString(const GPUStats& aStats);
      81             : 
      82             :   class Record {
      83             :   public:
      84          54 :     explicit Record(TimeStamp aStart = TimeStamp()) {
      85          54 :       if (gfxPrefs::LayersDrawFPS()) {
      86           0 :         mStart = aStart.IsNull() ? TimeStamp::Now() : aStart;
      87             :       }
      88          54 :     }
      89          54 :     bool Recording() const {
      90          54 :       return !mStart.IsNull();
      91             :     }
      92           0 :     float Duration() const {
      93           0 :       return (TimeStamp::Now() - mStart).ToMilliseconds();
      94             :     }
      95             : 
      96             :   private:
      97             :     TimeStamp mStart;
      98             :   };
      99             : 
     100             : private:
     101             :   FPSCounter mCompositeFps;
     102             :   FPSCounter mTransactionFps;
     103             :   TimedMetric mDlbMs;
     104             :   TimedMetric mFlbMs;
     105             :   TimedMetric mRasterMs;
     106             :   TimedMetric mSerializeMs;
     107             :   TimedMetric mSendMs;
     108             :   TimedMetric mUpdateMs;
     109             :   TimedMetric mPrepareMs;
     110             :   TimedMetric mCompositeMs;
     111             :   TimedMetric mGPUDrawMs;
     112             : };
     113             : 
     114             : } // namespace layers
     115             : } // namespace mozilla
     116             : 
     117             : #endif // mozilla_gfx_layers_composite_Diagnostics_h

Generated by: LCOV version 1.13