LCOV - code coverage report
Current view: top level - eq - nodeStatistics.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 1 31 3.2 %
Date: 2017-12-16 05:07:20 Functions: 2 5 40.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2009-2016, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                          Cedric Stalder <cedric.stalder@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 "nodeStatistics.h"
      20             : 
      21             : #include "config.h"
      22             : #include "global.h"
      23             : #include "node.h"
      24             : #include "pipe.h"
      25             : 
      26             : #include <cstdio>
      27             : 
      28             : #ifdef _MSC_VER
      29             : #define snprintf _snprintf
      30             : #endif
      31             : 
      32             : namespace eq
      33             : {
      34           0 : NodeStatistics::NodeStatistics(const Statistic::Type type, Node* node,
      35           0 :                                const uint32_t frameNumber)
      36           0 :     : StatisticSampler<Node>(type, node, frameNumber)
      37             : {
      38           0 :     const std::string& name = node->getName();
      39           0 :     if (name.empty())
      40           0 :         snprintf(statistic.resourceName, 32, "Node %s",
      41           0 :                  node->getID().getShortString().c_str());
      42             :     else
      43           0 :         snprintf(statistic.resourceName, 32, "%s", name.c_str());
      44             : 
      45           0 :     statistic.resourceName[31] = 0;
      46             : 
      47           0 :     co::LocalNodePtr localNode = node->getLocalNode();
      48           0 :     LBASSERT(localNode);
      49           0 :     if (!localNode)
      50             :     {
      51           0 :         statistic.frameNumber = 0;
      52           0 :         return;
      53             :     }
      54             : 
      55           0 :     Config* config = _owner->getConfig();
      56           0 :     statistic.startTime = config->getTime();
      57           0 :     LBASSERT(_owner->getID() != 0);
      58             : }
      59             : 
      60           0 : NodeStatistics::~NodeStatistics()
      61             : {
      62           0 :     if (statistic.frameNumber == 0) // does not belong to a frame
      63           0 :         return;
      64             : 
      65           0 :     co::LocalNodePtr localNode = _owner->getLocalNode();
      66           0 :     LBASSERT(localNode);
      67           0 :     if (!localNode)
      68           0 :         return;
      69             : 
      70           0 :     Config* config = _owner->getConfig();
      71           0 :     statistic.endTime = config->getTime();
      72           0 :     if (statistic.endTime <= statistic.startTime)
      73           0 :         statistic.endTime = statistic.startTime + 1;
      74           0 :     _owner->processEvent(statistic);
      75           0 : }
      76          30 : }

Generated by: LCOV version 1.11