LCOV - code coverage report
Current view: top level - eq/client - channelStatistics.cpp (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 32 34 94.1 %
Date: 2014-06-18 Functions: 4 5 80.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2006-2012, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                    2010, Daniel Nachbaur <danielnachbaur@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #include "channelStatistics.h"
      20             : 
      21             : #include "channel.h"
      22             : #include "config.h"
      23             : #include "global.h"
      24             : #include "pipe.h"
      25             : #include "window.h"
      26             : 
      27             : #include <cstdio>
      28             : 
      29             : #ifdef _MSC_VER
      30             : #  define snprintf _snprintf
      31             : #endif
      32             : 
      33             : namespace eq
      34             : {
      35             : 
      36          32 : ChannelStatistics::ChannelStatistics( const Statistic::Type type,
      37             :                                       Channel* channel, const uint32_t frame,
      38             :                                       const int32_t hint )
      39             :         : StatisticSampler< Channel >( type, channel, frame )
      40          32 :         , _hint( hint )
      41             : {
      42          32 :     if( _hint == AUTO )
      43          32 :         _hint = channel->getIAttribute( Channel::IATTR_HINT_STATISTICS );
      44          32 :     if( _hint == OFF )
      45          32 :         return;
      46             : 
      47          32 :     event.data.statistic.task = channel->getTaskID();
      48             : 
      49          32 :     const std::string& name = channel->getName();
      50          32 :     if( name.empty( ))
      51             :         snprintf( event.data.statistic.resourceName, 32, "Channel %s",
      52           0 :                   channel->getID().getShortString().c_str( ));
      53             :     else
      54          32 :         snprintf( event.data.statistic.resourceName, 32, "%s", name.c_str( ));
      55          32 :     event.data.statistic.resourceName[31] = 0;
      56             : 
      57          32 :     if( _hint == NICEST &&
      58          32 :         type != Statistic::CHANNEL_ASYNC_READBACK &&
      59          32 :         type != Statistic::CHANNEL_FRAME_TRANSMIT &&
      60          32 :         type != Statistic::CHANNEL_FRAME_COMPRESS &&
      61             :         type != Statistic::CHANNEL_FRAME_WAIT_SENDTOKEN )
      62             :     {
      63          32 :         channel->getWindow()->finish();
      64             :     }
      65             : 
      66          32 :     event.data.statistic.startTime  = channel->getConfig()->getTime();
      67             : }
      68             : 
      69             : 
      70          64 : ChannelStatistics::~ChannelStatistics()
      71             : {
      72          32 :     if( _hint == OFF )
      73           0 :         return;
      74             : 
      75          32 :     const Statistic::Type type = event.data.statistic.type;
      76          32 :     if( _hint == NICEST &&
      77          30 :         type != Statistic::CHANNEL_ASYNC_READBACK &&
      78          30 :         type != Statistic::CHANNEL_FRAME_TRANSMIT &&
      79          30 :         type != Statistic::CHANNEL_FRAME_COMPRESS &&
      80             :         type != Statistic::CHANNEL_FRAME_WAIT_SENDTOKEN )
      81             :     {
      82          30 :         _owner->getWindow()->finish();
      83             :     }
      84             : 
      85          32 :     if( event.data.statistic.endTime == 0 )
      86          32 :         event.data.statistic.endTime = _owner->getConfig()->getTime();
      87          32 :     if( event.data.statistic.endTime <= event.data.statistic.startTime )
      88           2 :         event.data.statistic.endTime = event.data.statistic.startTime + 1;
      89             : 
      90          32 :     _owner->addStatistic( event.data );
      91          32 : }
      92             : 
      93          36 : }

Generated by: LCOV version 1.10