channelStatistics.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "channelStatistics.h"
00019
00020 #include "channel.h"
00021 #include "config.h"
00022 #include "global.h"
00023 #include "pipe.h"
00024 #include "window.h"
00025
00026 #ifdef WIN32_VC
00027 # define snprintf _snprintf
00028 #endif
00029
00030 namespace eq
00031 {
00032
00033 ChannelStatistics::ChannelStatistics( const Statistic::Type type,
00034 Channel* channel )
00035 : StatisticSampler< Channel >( type, channel,
00036 channel->getPipe()->getCurrentFrame( ))
00037 {
00038 const int32_t hint = channel->getIAttribute(Channel::IATTR_HINT_STATISTICS);
00039 if( hint == OFF )
00040 return;
00041
00042 event.data.statistic.task = channel->getTaskID();
00043
00044 const std::string& name = channel->getName();
00045 if( name.empty( ))
00046 snprintf( event.data.statistic.resourceName, 32, "channel %d",
00047 channel->getID( ));
00048 else
00049 snprintf( event.data.statistic.resourceName, 32, "%s", name.c_str( ));
00050
00051 if( hint == NICEST )
00052 channel->getWindow()->finish();
00053
00054 event.data.statistic.startTime = channel->getConfig()->getTime();
00055 event.data.statistic.endTime = 0;
00056 }
00057
00058
00059 ChannelStatistics::~ChannelStatistics()
00060 {
00061 const int32_t hint = _owner->getIAttribute( Channel::IATTR_HINT_STATISTICS);
00062 if( hint == OFF )
00063 return;
00064
00065 if( hint == NICEST )
00066 _owner->getWindow()->finish();
00067
00068 if( event.data.statistic.endTime == 0 )
00069 event.data.statistic.endTime = _owner->getConfig()->getTime();
00070
00071 _owner->addStatistic( event.data );
00072 }
00073
00074 }