Line data Source code
1 :
2 : /* Copyright (c) 2006-2016, Stefan Eilemann <eile@equalizergraphics.com>
3 : * 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 11 : ChannelStatistics::ChannelStatistics(const Statistic::Type type,
36 : Channel* channel, const uint32_t frame,
37 11 : const int32_t hint)
38 : : StatisticSampler<Channel>(type, channel, frame)
39 11 : , _hint(hint)
40 : {
41 11 : if (_hint == AUTO)
42 9 : _hint = channel->getIAttribute(Channel::IATTR_HINT_STATISTICS);
43 11 : if (_hint == OFF)
44 0 : return;
45 :
46 11 : statistic.task = channel->getTaskID();
47 :
48 11 : const std::string& name = channel->getName();
49 11 : if (name.empty())
50 0 : snprintf(statistic.resourceName, 32, "Channel %s",
51 0 : channel->getID().getShortString().c_str());
52 : else
53 11 : snprintf(statistic.resourceName, 32, "%s", name.c_str());
54 11 : statistic.resourceName[31] = 0;
55 :
56 11 : if (_hint == NICEST && type != Statistic::CHANNEL_ASYNC_READBACK &&
57 11 : type != Statistic::CHANNEL_FRAME_TRANSMIT &&
58 11 : type != Statistic::CHANNEL_FRAME_COMPRESS &&
59 : type != Statistic::CHANNEL_FRAME_WAIT_SENDTOKEN)
60 : {
61 11 : channel->getWindow()->finish();
62 : }
63 :
64 11 : statistic.startTime = channel->getConfig()->getTime();
65 : }
66 :
67 22 : ChannelStatistics::~ChannelStatistics()
68 : {
69 11 : if (_hint == OFF)
70 0 : return;
71 :
72 11 : const Statistic::Type type = statistic.type;
73 11 : if (_hint == NICEST && type != Statistic::CHANNEL_ASYNC_READBACK &&
74 10 : type != Statistic::CHANNEL_FRAME_TRANSMIT &&
75 10 : type != Statistic::CHANNEL_FRAME_COMPRESS &&
76 : type != Statistic::CHANNEL_FRAME_WAIT_SENDTOKEN)
77 : {
78 10 : _owner->getWindow()->finish();
79 : }
80 :
81 11 : if (statistic.endTime == 0)
82 11 : statistic.endTime = _owner->getConfig()->getTime();
83 11 : if (statistic.endTime <= statistic.startTime)
84 4 : statistic.endTime = statistic.startTime + 1;
85 :
86 11 : _owner->addStatistic(statistic);
87 11 : }
88 30 : }
|