27 #ifndef STATSRENDERER_H
28 #define STATSRENDERER_H
38 #include <sys/types.h>
47 typedef typename GC::CORE_CONFIG CC;
53 virtual const char * GetLabel()
const = 0;
70 virtual const char * GetLabel()
const = 0;
72 virtual s32 GetDecimalPlaces()
const = 0;
74 virtual double GetValue(
bool endOfEpoch)
const = 0;
78 const u32 FMT_BUFFER_SIZE = 32;
79 char fmtBuffer[FMT_BUFFER_SIZE];
81 const u32 STR_BUFFER_SIZE = 128;
82 char strBuffer[STR_BUFFER_SIZE];
84 s32 places = GetDecimalPlaces();
87 snprintf(fmtBuffer, FMT_BUFFER_SIZE,
"%%8.%df",places);
88 snprintf(strBuffer, STR_BUFFER_SIZE, fmtBuffer, GetValue(endOfEpoch));
115 virtual const char * GetLabel()
const
119 return m_element->GetUUID().GetLabel();
126 if (!m_element || !m_grid)
130 u32 type = m_element->GetType();
131 u32 allSites = m_grid->CountActiveSites();
132 u32 count = m_grid->GetAtomCount(type);
133 double pct = 100.0 * count / allSites;
135 if (pct == 0 || pct >= 1)
137 bs.Printf(
"%d %2d", count, (
int) pct);
141 bs.Printf(
"%d .%d", count, (
int) (10 * pct));
150 const char * m_label;
166 void Set(
Grid<GC> & grid,
const char * label, u32 elementType,
167 u32 slot, u32 outOfSlots,
bool resetOnRead)
171 m_elementType = elementType;
173 m_outOfSlots = outOfSlots;
174 m_resetOnRead = resetOnRead;
177 virtual const char * GetLabel()
const
186 virtual s32 GetDecimalPlaces()
const
190 virtual double GetValue(
bool endOfEpoch)
const
196 if (m_slot >= m_outOfSlots)
206 u64 * eds = et.GetElementDataSlotsFromType(m_elementType,m_outOfSlots);
212 if (endOfEpoch && m_resetOnRead)
226 static const u32 MAX_TYPES = 32;
228 u32 m_reportersInUse;
231 u32 m_displayElementsInUse;
236 static const u32 MAX_BUTTONS = 16;
238 u32 m_registeredButtons;
243 m_displayElementsInUse(0),
246 m_registeredButtons(0)
251 m_registeredButtons = 0;
255 BUTTON_HEIGHT_PIXELS = 20,
256 LINE_HEIGHT_PIXELS = 32,
257 DETAIL_LINE_HEIGHT_PIXELS = 32
259 void ReassignButtonLocations()
261 SPoint loc(4, m_reportersInUse * BUTTON_HEIGHT_PIXELS);
262 loc.SetY(loc.GetY() + m_displayAER*LINE_HEIGHT_PIXELS);
263 for(u32 i = 0; i < m_registeredButtons; i++)
266 loc.SetY(loc.GetY() + BUTTON_HEIGHT_PIXELS);
270 void AddButton(AbstractButton* b)
272 if (m_registeredButtons >= MAX_BUTTONS)
275 SPoint dimensions(268, BUTTON_HEIGHT_PIXELS - 2);
276 SPoint location(4, (m_reportersInUse + m_registeredButtons) * BUTTON_HEIGHT_PIXELS);
277 b->SetDimensions(dimensions);
278 b->SetLocation(location);
280 m_buttons[m_registeredButtons++] = b;
286 u32 GetDisplayAER()
const
291 u32 GetMaxDisplayAER()
const
293 return m_maxDisplayAER;
296 void SetDisplayAER(u32 displayAER)
298 m_displayAER = displayAER % (m_maxDisplayAER + 1);
299 ReassignButtonLocations();
302 bool DisplayDataReporter(
const DataReporter * cs)
304 if (m_reportersInUse >= MAX_TYPES)
308 u32 index = m_reportersInUse++;
309 m_reporters[index] = cs;
313 bool DisplayStatsForElement(
const Grid<GC> & grd,
const Element<CC> & elt)
315 if (m_displayElementsInUse >= MAX_TYPES)
319 u32 index = m_displayElementsInUse++;
320 m_displayElements[index].Set(&grd,&elt);
321 return DisplayDataReporter(&m_displayElements[index]);
324 void SetDrawPoint(Point<s32> drawPoint)
326 m_drawPoint = drawPoint;
329 void SetDimensions(Point<u32> dimensions)
331 m_dimensions = dimensions;
334 void RenderGridStatistics(Drawing & drawing, Grid<GC>& grid,
double aeps,
double aer, u32 AEPSperFrame,
double overhead,
bool endOfEpoch);
336 void WriteRegisteredCounts(ByteSink & fp,
bool writeHeader, Grid<GC>& grid,
double aeps,
double aer, u32 AEPSperFrame,
double overhead,
bool doResets);
339 #include "StatsRenderer.tcc"
Definition: StatsRenderer.h:67
virtual void GetValue(ByteSink &bs, bool endOfEpoch) const
Definition: StatsRenderer.h:124
Definition: StatsRenderer.h:50
virtual void GetValue(ByteSink &bs, bool endOfEpoch) const
Definition: StatsRenderer.h:76
Definition: StatsRenderer.h:146
Definition: ByteSink.h:47
void Print(const char *str, s32 fieldWidth=-1, u8 padChar= ' ')
Definition: ByteSink.cpp:31
Definition: StatsRenderer.h:44
Definition: EventWindow.h:41
Definition: ElementTable.h:46
ElementTable< CC > & GetElementTable()
Definition: Tile.h:599
virtual void GetValue(ByteSink &bs, bool endOfEpoch) const =0
Definition: StatsRenderer.h:97