IGUIProfiler has now more and better display filters.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4973 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2014-10-15 18:47:35 +00:00
parent b6f767b182
commit 323aea6ab9
6 changed files with 55 additions and 51 deletions

View File

@ -101,7 +101,7 @@ class MyEventReceiver : public IEventReceiver
{
public:
// constructor
MyEventReceiver(ISceneManager * smgr) : GuiProfiler(0), IncludeOverview(true), ActiveScene(ES_NONE), SceneManager(smgr) {}
MyEventReceiver(ISceneManager * smgr) : GuiProfiler(0), IncludeOverview(true), IgnoreUncalled(false), ActiveScene(ES_NONE), SceneManager(smgr) {}
virtual bool OnEvent(const SEvent& event)
{
@ -131,7 +131,11 @@ public:
GuiProfiler->firstPage(IncludeOverview); // not strictly needed, but otherwise the update won't update
break;
case KEY_F6:
GuiProfiler->setIgnoreUncalled( !GuiProfiler->getIgnoreUncalled() );
/*
You can set more filters. This one filters out profile data which was never called.
*/
IgnoreUncalled = !IgnoreUncalled;
GuiProfiler->setFilters(IgnoreUncalled ? 1 : 0, 0, 0.f, 0);
break;
case KEY_F7:
GuiProfiler->setShowGroupsTogether( !GuiProfiler->getShowGroupsTogether() );
@ -282,6 +286,7 @@ public:
IGUIProfiler * GuiProfiler;
bool IncludeOverview;
bool IgnoreUncalled;
u32 ActiveScene;
scene::ISceneManager* SceneManager;
};

View File

@ -44,12 +44,6 @@ namespace gui
//! Can several groups be displayed per page?
virtual bool getShowGroupsTogether() const = 0;
//! Don't display stats for data which never got called
virtual void setIgnoreUncalled(bool ignore) = 0;
//! Check if we display stats for data which never got called
virtual bool getIgnoreUncalled() const = 0;
//! Sets another skin independent font.
/** If this is set to zero, the button uses the font of the skin.
\param font: New font to set. */
@ -77,6 +71,9 @@ namespace gui
//! Are updates currently frozen
virtual bool getFrozen() const = 0;
//! Filters prevents data that doesn't achieve the conditions from being displayed
virtual void setFilters(irr::u32 minCalls = 0, irr::u32 minTimeSum = 0, irr::f32 minTimeAverage = 0.f, irr::u32 minTimeMax = 0) = 0;
};
} // end namespace gui

View File

@ -60,7 +60,7 @@ struct SProfileData
}
//! Time spend between start/stop
s32 getTimeSum() const
u32 getTimeSum() const
{
return TimeSum;
}

View File

@ -1131,7 +1131,7 @@ IGUITable* CGUIEnvironment::addTable(const core::rect<s32>& rectangle, IGUIEleme
//! Adds an element to display the information from the Irrlicht profiler
IGUIProfiler* CGUIEnvironment::addProfilerDisplay(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id)
{
CGUIProfiler* p = new CGUIProfiler(this, parent ? parent : this, id, rectangle);
CGUIProfiler* p = new CGUIProfiler(this, parent ? parent : this, id, rectangle, NULL);
p->drop();
return p;
}

View File

@ -19,8 +19,9 @@ namespace gui
CGUIProfiler::CGUIProfiler(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle, IProfiler* profiler)
: IGUIProfiler(environment, parent, id, rectangle, profiler)
, Profiler(profiler)
, DisplayTable(0), CurrentGroupIdx(0), CurrentGroupPage(0), NumGroupPages(1), IgnoreUncalled(false)
, DisplayTable(0), CurrentGroupIdx(0), CurrentGroupPage(0), NumGroupPages(1)
, DrawBackground(false), Frozen(false), UnfreezeOnce(false), ShowGroupsTogether(false)
, MinCalls(0), MinTimeSum(0), MinTimeAverage(0.f), MinTimeMax(0)
{
if ( !Profiler )
Profiler = &getProfiler();
@ -69,6 +70,24 @@ void CGUIProfiler::rebuildColumns()
}
}
u32 CGUIProfiler::addDataToTable(u32 rowIndex, u32 dataIndex, u32 groupIndex)
{
const SProfileData& data = Profiler->getProfileDataByIndex(dataIndex);
if ( data.getGroupIndex() == groupIndex
&& data.getCallsCounter() >= MinCalls
&& ( data.getCallsCounter() == 0 ||
(data.getTimeSum() >= MinTimeSum &&
(f32)data.getTimeSum()/(f32)data.getCallsCounter() >= MinTimeAverage &&
data.getLongestTime() >= MinTimeMax))
)
{
rowIndex = DisplayTable->addRow(rowIndex);
fillRow(rowIndex, data, false, false);
++rowIndex;
}
return rowIndex;
}
void CGUIProfiler::updateDisplay()
{
if ( DisplayTable )
@ -79,21 +98,23 @@ void CGUIProfiler::updateDisplay()
{
bool overview = CurrentGroupIdx == 0;
u32 rowIndex = 0;
// show description row (overview or name of the following group)
const SProfileData& groupData = Profiler->getGroupData(CurrentGroupIdx);
if ( !ShowGroupsTogether && (overview || !IgnoreUncalled || groupData.getCallsCounter() > 0) )
if ( !ShowGroupsTogether && (overview || groupData.getCallsCounter() >= MinCalls) )
{
rowIndex = DisplayTable->addRow(rowIndex);
fillRow(rowIndex, groupData, overview, true);
++rowIndex;
}
// show overview over groups?
// show overview over all groups?
if ( overview )
{
for ( u32 i=1; i<Profiler->getGroupCount(); ++i )
{
const SProfileData& groupData = Profiler->getGroupData(i);
if ( !IgnoreUncalled || groupData.getCallsCounter() > 0 )
if ( groupData.getCallsCounter() >= MinCalls )
{
rowIndex = DisplayTable->addRow(rowIndex);
fillRow(rowIndex, groupData, false, false);
@ -106,14 +127,7 @@ void CGUIProfiler::updateDisplay()
{
for ( u32 i=0; i < Profiler->getProfileDataCount(); ++i )
{
const SProfileData& data = Profiler->getProfileDataByIndex(i);
if ( data.getGroupIndex() == CurrentGroupIdx
&& (!IgnoreUncalled || data.getCallsCounter() > 0) )
{
rowIndex = DisplayTable->addRow(rowIndex);
fillRow(rowIndex, data, false, false);
++rowIndex;
}
rowIndex = addDataToTable(rowIndex, i, CurrentGroupIdx);
}
}
// Show the rest of the groups
@ -123,14 +137,7 @@ void CGUIProfiler::updateDisplay()
{
for ( u32 i=0; i < Profiler->getProfileDataCount(); ++i )
{
const SProfileData& data = Profiler->getProfileDataByIndex(i);
if ( data.getGroupIndex() == groupIdx
&& (!IgnoreUncalled || data.getCallsCounter() > 0) )
{
rowIndex = DisplayTable->addRow(rowIndex);
fillRow(rowIndex, data, false, false);
++rowIndex;
}
rowIndex = addDataToTable(rowIndex, i, groupIdx);
}
}
}
@ -257,17 +264,6 @@ void CGUIProfiler::firstPage(bool includeOverview)
CurrentGroupPage = 0;
}
void CGUIProfiler::setIgnoreUncalled(bool ignore)
{
IgnoreUncalled = ignore;
}
bool CGUIProfiler::getIgnoreUncalled() const
{
return IgnoreUncalled;
}
//! Sets another skin independent font.
void CGUIProfiler::setOverrideFont(IGUIFont* font)
{
@ -320,6 +316,13 @@ bool CGUIProfiler::getFrozen() const
return Frozen;
}
void CGUIProfiler::setFilters(irr::u32 minCalls, irr::u32 minTimeSum, irr::f32 minTimeAverage, irr::u32 minTimeMax)
{
MinCalls = minCalls;
MinTimeSum = minTimeSum;
MinTimeAverage = minTimeAverage;
MinTimeMax = minTimeMax;
}
} // end namespace gui
} // end namespace irr

View File

@ -25,7 +25,7 @@ namespace gui
{
public:
//! constructor
CGUIProfiler(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle, IProfiler* profiler = NULL);
CGUIProfiler(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle, IProfiler* profiler);
//! Show first page of profile data
virtual void firstPage(bool includeOverview) _IRR_OVERRIDE_;
@ -43,15 +43,8 @@ namespace gui
//! Can several groups be displayed per page?
virtual bool getShowGroupsTogether() const _IRR_OVERRIDE_;
//! Don't display stats for data which never got called
/** Default is false */
virtual void setIgnoreUncalled(bool ignore) _IRR_OVERRIDE_;
//! Check if we display stats for data which never got called
virtual bool getIgnoreUncalled() const _IRR_OVERRIDE_;
//! Sets another skin independent font.
virtual void setOverrideFont(IGUIFont* font=0) _IRR_OVERRIDE_;
virtual void setOverrideFont(IGUIFont* font) _IRR_OVERRIDE_;
//! Gets the override font (if any)
virtual IGUIFont* getOverrideFont() const _IRR_OVERRIDE_;
@ -72,6 +65,8 @@ namespace gui
//! Are updates currently frozen
virtual bool getFrozen() const _IRR_OVERRIDE_;
//! Filters prevents data that doesn't achieve the conditions from being displayed
virtual void setFilters(irr::u32 minCalls, irr::u32 minTimeSum, irr::f32 minTimeAverage, irr::u32 minTimeMax) _IRR_OVERRIDE_;
virtual IGUIElement* getElementFromPoint(const core::position2d<s32>& point) _IRR_OVERRIDE_
{
@ -85,6 +80,7 @@ namespace gui
void updateDisplay();
void fillRow(u32 rowIndex, const SProfileData& data, bool overviewTitle, bool groupTitle);
u32 addDataToTable(u32 rowIndex, u32 dataIndex, u32 groupIndex);
void rebuildColumns();
IProfiler * Profiler;
@ -92,11 +88,14 @@ namespace gui
irr::u32 CurrentGroupIdx;
irr::s32 CurrentGroupPage;
irr::s32 NumGroupPages;
bool IgnoreUncalled;
bool DrawBackground;
bool Frozen;
bool UnfreezeOnce;
bool ShowGroupsTogether;
irr::u32 MinCalls;
irr::u32 MinTimeSum;
irr::f32 MinTimeAverage;
irr::u32 MinTimeMax;
};
} // end namespace gui