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