Line data Source code
1 :
2 : /* Copyright (c) 2009-2016, Stefan Eilemann <eile@equalizergraphics.com>
3 : *
4 : * This library is free software; you can redistribute it and/or modify it under
5 : * the terms of the GNU Lesser General Public License version 2.1 as published
6 : * by the Free Software Foundation.
7 : *
8 : * This library is distributed in the hope that it will be useful, but WITHOUT
9 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 : * details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this library; if not, write to the Free Software Foundation, Inc.,
15 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 : */
17 :
18 : #include "statistic.h"
19 :
20 : #include <vmmlib/vector.hpp>
21 : #include <string>
22 :
23 : #ifdef _WIN32
24 : # define bzero( ptr, size ) memset( ptr, 0, size );
25 : #else
26 : # include <strings.h>
27 : #endif
28 :
29 : namespace eq
30 : {
31 : namespace fabric
32 : {
33 : namespace
34 : {
35 644 : struct StatisticData
36 : {
37 : const Statistic::Type type;
38 : const std::string name;
39 : const Vector3f color;
40 : };
41 :
42 56 : static StatisticData _statisticData[] =
43 : {{ Statistic::NONE,
44 : "NO EVENT", Vector3f( 0.f, 0.f, 0.f ) },
45 : { Statistic::CHANNEL_CLEAR,
46 : "clear", Vector3f( .5f, 1.0f, .5f ) },
47 : { Statistic::CHANNEL_DRAW,
48 : "draw", Vector3f( 0.f, .9f, 0.f ) },
49 : { Statistic::CHANNEL_DRAW_FINISH,
50 : "finish draw", Vector3f( 0.f, .5f, 0.f ) },
51 : { Statistic::CHANNEL_ASSEMBLE,
52 : "assemble", Vector3f( 1.0f, 1.0f, 0.f ) },
53 : { Statistic::CHANNEL_FRAME_WAIT_READY,
54 : "wait frame", Vector3f( 1.0f, 0.f, 0.f ) },
55 : { Statistic::CHANNEL_READBACK,
56 : "readback", Vector3f( 1.0f, .5f, .5f ) },
57 : { Statistic::CHANNEL_ASYNC_READBACK,
58 : "readback", Vector3f( 1.0f, .5f, .5f ) },
59 : { Statistic::CHANNEL_VIEW_FINISH,
60 : "view finish", Vector3f( 1.f, 0.f, 1.0f ) },
61 : { Statistic::CHANNEL_FRAME_TRANSMIT,
62 : "transmit", Vector3f( 0.f, 0.f, 1.0f ) },
63 : { Statistic::CHANNEL_FRAME_COMPRESS,
64 : "compress", Vector3f( 0.f, .7f, 1.f ) },
65 : { Statistic::CHANNEL_FRAME_WAIT_SENDTOKEN,
66 : "wait send token", Vector3f( 1.f, 0.f, 0.f ) },
67 : { Statistic::WINDOW_FINISH,
68 : "finish", Vector3f( 1.0f, 1.0f, 0.f ) },
69 : { Statistic::WINDOW_THROTTLE_FRAMERATE,
70 : "throttle", Vector3f( 1.0f, 0.f, 1.f ) },
71 : { Statistic::WINDOW_SWAP_BARRIER,
72 : "barrier", Vector3f( 1.0f, 0.f, 0.f ) },
73 : { Statistic::WINDOW_SWAP,
74 : "swap", Vector3f( 1.f, 1.f, 1.f ) },
75 : { Statistic::WINDOW_FPS,
76 : "FPS", Vector3f( 1.f, 1.f, 1.f ) },
77 : { Statistic::PIPE_IDLE,
78 : "pipe idle", Vector3f( 1.f, 1.f, 1.f ) },
79 : { Statistic::NODE_FRAME_DECOMPRESS,
80 : "decompress", Vector3f( 0.f, .7f, 1.f ) },
81 : { Statistic::CONFIG_START_FRAME,
82 : "start frame", Vector3f( .5f, 1.0f, .5f ) },
83 : { Statistic::CONFIG_FINISH_FRAME,
84 : "finish frame", Vector3f( .5f, .5f, .5f ) },
85 : { Statistic::CONFIG_WAIT_FINISH_FRAME,
86 : "wait finish", Vector3f( 1.0f, 0.f, 0.f ) },
87 : { Statistic::ALL,
88 28 : "ALL EVENTS", Vector3f( 0.0f, 0.f, 0.f ) }} ;
89 : }
90 :
91 0 : const std::string& Statistic::getName( const Type type )
92 : {
93 0 : LBASSERTINFO( _statisticData[ type ].type == type, int( type ));
94 0 : return _statisticData[ type ].name;
95 : }
96 :
97 0 : const Vector3f& Statistic::getColor( const Type type )
98 : {
99 0 : LBASSERTINFO( _statisticData[ type ].type == type, type );
100 0 : return _statisticData[ type ].color;
101 : }
102 :
103 0 : std::ostream& operator << ( std::ostream& os, const Statistic::Type& type )
104 : {
105 0 : os << Statistic::getName( type );
106 0 : return os;
107 : }
108 :
109 0 : std::ostream& operator << ( std::ostream& os, const Statistic& event )
110 : {
111 0 : os << event.resourceName << ": " << event.type << ' ' << event.frameNumber
112 0 : << ' ' << event.task << ' ' << event.startTime << " - " << event.endTime
113 0 : << ' ' << event.idleTime << '/' << event.totalTime;
114 0 : return os;
115 : }
116 :
117 : }
118 84 : }
|