LCOV - code coverage report
Current view: top level - gfx/layers/composite - Diagnostics.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 3 52 5.8 %
Date: 2017-07-14 16:53:18 Functions: 1 4 25.0 %
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             : #include "Diagnostics.h"
       7             : #include "mozilla/layers/LayersMessages.h"
       8             : #include "nsPrintfCString.h"
       9             : 
      10             : namespace mozilla {
      11             : namespace layers {
      12             : 
      13             : float
      14           0 : TimedMetric::Average() const
      15             : {
      16             :   // We take at most 2 seconds of history.
      17           0 :   TimeStamp latest = TimeStamp::Now();
      18           0 :   float total = 0.0f;
      19           0 :   size_t count = 0;
      20           0 :   for (auto iter = mHistory.rbegin(); iter != mHistory.rend(); iter++) {
      21           0 :     if ((latest - iter->second).ToSeconds() > 2.0f) {
      22           0 :       break;
      23             :     }
      24           0 :     total += iter->first;
      25           0 :     count++;
      26             :   }
      27             : 
      28           0 :   if (!count) {
      29           0 :     return 0.0f;
      30             :   }
      31           0 :   return total / float(count);
      32             : }
      33             : 
      34           1 : Diagnostics::Diagnostics()
      35             :  : mCompositeFps("Compositor"),
      36           1 :    mTransactionFps("LayerTransactions")
      37             : {
      38           1 : }
      39             : 
      40             : void
      41           0 : Diagnostics::RecordPaintTimes(const PaintTiming& aPaintTimes)
      42             : {
      43           0 :   mDlbMs.Add(aPaintTimes.dlMs());
      44           0 :   mFlbMs.Add(aPaintTimes.flbMs());
      45           0 :   mRasterMs.Add(aPaintTimes.rasterMs());
      46           0 :   mSerializeMs.Add(aPaintTimes.serializeMs());
      47           0 :   mSendMs.Add(aPaintTimes.sendMs());
      48           0 : }
      49             : 
      50             : std::string
      51           0 : Diagnostics::GetFrameOverlayString(const GPUStats& aStats)
      52             : {
      53           0 :   TimeStamp now = TimeStamp::Now();
      54           0 :   unsigned fps = unsigned(mCompositeFps.AddFrameAndGetFps(now));
      55           0 :   unsigned txnFps = unsigned(mTransactionFps.GetFPS(now));
      56             : 
      57           0 :   float pixelFillRatio = aStats.mInvalidPixels
      58           0 :                          ? float(aStats.mPixelsFilled) / float(aStats.mInvalidPixels)
      59           0 :                          : 0.0f;
      60           0 :   float screenFillRatio = aStats.mScreenPixels
      61           0 :                           ? float(aStats.mPixelsFilled) / float(aStats.mScreenPixels)
      62           0 :                           : 0.0f;
      63             : 
      64           0 :   if (aStats.mDrawTime) {
      65           0 :     mGPUDrawMs.Add(aStats.mDrawTime.value());
      66             :   }
      67             : 
      68           0 :   std::string gpuTimeString;
      69           0 :   if (mGPUDrawMs.Empty()) {
      70           0 :     gpuTimeString = "N/A";
      71             :   } else {
      72           0 :     gpuTimeString = nsPrintfCString("%0.1fms", mGPUDrawMs.Average()).get();
      73             :   }
      74             : 
      75             :   // DL  = nsDisplayListBuilder
      76             :   // FLB = FrameLayerBuilder
      77             :   // R   = ClientLayerManager::EndTransaction
      78             :   // CP  = ShadowLayerForwarder::EndTransaction (txn build)
      79             :   // TX  = LayerTransactionChild::SendUpdate (IPDL serialize+send)
      80             :   // UP  = LayerTransactionParent::RecvUpdate (IPDL deserialize, update, APZ update)
      81             :   // CC_BUILD = Container prepare/composite frame building
      82             :   // CC_EXEC  = Container render/composite drawing
      83           0 :   nsPrintfCString line1("FPS: %d (TXN: %d)", fps, txnFps);
      84             :   nsPrintfCString line2("[CC] Build: %0.1fms Exec: %0.1fms GPU: %s Fill Ratio: %0.1f/%0.1f",
      85           0 :     mPrepareMs.Average(),
      86           0 :     mCompositeMs.Average(),
      87             :     gpuTimeString.c_str(),
      88             :     pixelFillRatio,
      89           0 :     screenFillRatio);
      90             :   nsPrintfCString line3("[Content] DL: %0.1fms FLB: %0.1fms Raster: %0.1fms",
      91           0 :     mDlbMs.Average(),
      92           0 :     mFlbMs.Average(),
      93           0 :     mRasterMs.Average());
      94             :   nsPrintfCString line4("[IPDL] Build: %0.1fms Send: %0.1fms Update: %0.1fms",
      95           0 :     mSerializeMs.Average(),
      96           0 :     mSendMs.Average(),
      97           0 :     mUpdateMs.Average());
      98             : 
      99           0 :   return std::string(line1.get()) + "\n" +
     100           0 :          std::string(line2.get()) + "\n" +
     101           0 :          std::string(line3.get()) + "\n" +
     102           0 :          std::string(line4.get());
     103             : }
     104             : 
     105             : } // namespace layers
     106             : } // namespace mozilla

Generated by: LCOV version 1.13