Commit 323aea6a authored by cutealien's avatar cutealien

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
parent b6f767b1
...@@ -101,7 +101,7 @@ class MyEventReceiver : public IEventReceiver ...@@ -101,7 +101,7 @@ class MyEventReceiver : public IEventReceiver
{ {
public: public:
// constructor // 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) virtual bool OnEvent(const SEvent& event)
{ {
...@@ -131,7 +131,11 @@ public: ...@@ -131,7 +131,11 @@ public:
GuiProfiler->firstPage(IncludeOverview); // not strictly needed, but otherwise the update won't update GuiProfiler->firstPage(IncludeOverview); // not strictly needed, but otherwise the update won't update
break; break;
case KEY_F6: 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; break;
case KEY_F7: case KEY_F7:
GuiProfiler->setShowGroupsTogether( !GuiProfiler->getShowGroupsTogether() ); GuiProfiler->setShowGroupsTogether( !GuiProfiler->getShowGroupsTogether() );
...@@ -282,6 +286,7 @@ public: ...@@ -282,6 +286,7 @@ public:
IGUIProfiler * GuiProfiler; IGUIProfiler * GuiProfiler;
bool IncludeOverview; bool IncludeOverview;
bool IgnoreUncalled;
u32 ActiveScene; u32 ActiveScene;
scene::ISceneManager* SceneManager; scene::ISceneManager* SceneManager;
}; };
......
...@@ -44,12 +44,6 @@ namespace gui ...@@ -44,12 +44,6 @@ namespace gui
//! Can several groups be displayed per page? //! Can several groups be displayed per page?
virtual bool getShowGroupsTogether() const = 0; 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. //! Sets another skin independent font.
/** If this is set to zero, the button uses the font of the skin. /** If this is set to zero, the button uses the font of the skin.
\param font: New font to set. */ \param font: New font to set. */
...@@ -77,6 +71,9 @@ namespace gui ...@@ -77,6 +71,9 @@ namespace gui
//! Are updates currently frozen //! Are updates currently frozen
virtual bool getFrozen() const = 0; 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 } // end namespace gui
......
...@@ -60,7 +60,7 @@ struct SProfileData ...@@ -60,7 +60,7 @@ struct SProfileData
} }
//! Time spend between start/stop //! Time spend between start/stop
s32 getTimeSum() const u32 getTimeSum() const
{ {
return TimeSum; return TimeSum;
} }
......
...@@ -1131,7 +1131,7 @@ IGUITable* CGUIEnvironment::addTable(const core::rect<s32>& rectangle, IGUIEleme ...@@ -1131,7 +1131,7 @@ IGUITable* CGUIEnvironment::addTable(const core::rect<s32>& rectangle, IGUIEleme
//! Adds an element to display the information from the Irrlicht profiler //! Adds an element to display the information from the Irrlicht profiler
IGUIProfiler* CGUIEnvironment::addProfilerDisplay(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id) 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(); p->drop();
return p; return p;
} }
......
...@@ -19,8 +19,9 @@ namespace gui ...@@ -19,8 +19,9 @@ namespace gui
CGUIProfiler::CGUIProfiler(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle, IProfiler* profiler) CGUIProfiler::CGUIProfiler(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle, IProfiler* profiler)
: IGUIProfiler(environment, parent, id, rectangle, profiler) : IGUIProfiler(environment, parent, id, rectangle, profiler)
, Profiler(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) , DrawBackground(false), Frozen(false), UnfreezeOnce(false), ShowGroupsTogether(false)
, MinCalls(0), MinTimeSum(0), MinTimeAverage(0.f), MinTimeMax(0)
{ {
if ( !Profiler ) if ( !Profiler )
Profiler = &getProfiler(); Profiler = &getProfiler();
...@@ -69,6 +70,24 @@ void CGUIProfiler::rebuildColumns() ...@@ -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() void CGUIProfiler::updateDisplay()
{ {
if ( DisplayTable ) if ( DisplayTable )
...@@ -79,21 +98,23 @@ void CGUIProfiler::updateDisplay() ...@@ -79,21 +98,23 @@ void CGUIProfiler::updateDisplay()
{ {
bool overview = CurrentGroupIdx == 0; bool overview = CurrentGroupIdx == 0;
u32 rowIndex = 0; u32 rowIndex = 0;
// show description row (overview or name of the following group)
const SProfileData& groupData = Profiler->getGroupData(CurrentGroupIdx); const SProfileData& groupData = Profiler->getGroupData(CurrentGroupIdx);
if ( !ShowGroupsTogether && (overview || !IgnoreUncalled || groupData.getCallsCounter() > 0) ) if ( !ShowGroupsTogether && (overview || groupData.getCallsCounter() >= MinCalls) )
{ {
rowIndex = DisplayTable->addRow(rowIndex); rowIndex = DisplayTable->addRow(rowIndex);
fillRow(rowIndex, groupData, overview, true); fillRow(rowIndex, groupData, overview, true);
++rowIndex; ++rowIndex;
} }
// show overview over groups? // show overview over all groups?
if ( overview ) if ( overview )
{ {
for ( u32 i=1; i<Profiler->getGroupCount(); ++i ) for ( u32 i=1; i<Profiler->getGroupCount(); ++i )
{ {
const SProfileData& groupData = Profiler->getGroupData(i); const SProfileData& groupData = Profiler->getGroupData(i);
if ( !IgnoreUncalled || groupData.getCallsCounter() > 0 ) if ( groupData.getCallsCounter() >= MinCalls )
{ {
rowIndex = DisplayTable->addRow(rowIndex); rowIndex = DisplayTable->addRow(rowIndex);
fillRow(rowIndex, groupData, false, false); fillRow(rowIndex, groupData, false, false);
...@@ -106,14 +127,7 @@ void CGUIProfiler::updateDisplay() ...@@ -106,14 +127,7 @@ void CGUIProfiler::updateDisplay()
{ {
for ( u32 i=0; i < Profiler->getProfileDataCount(); ++i ) for ( u32 i=0; i < Profiler->getProfileDataCount(); ++i )
{ {
const SProfileData& data = Profiler->getProfileDataByIndex(i); rowIndex = addDataToTable(rowIndex, i, CurrentGroupIdx);
if ( data.getGroupIndex() == CurrentGroupIdx
&& (!IgnoreUncalled || data.getCallsCounter() > 0) )
{
rowIndex = DisplayTable->addRow(rowIndex);
fillRow(rowIndex, data, false, false);
++rowIndex;
}
} }
} }
// Show the rest of the groups // Show the rest of the groups
...@@ -123,14 +137,7 @@ void CGUIProfiler::updateDisplay() ...@@ -123,14 +137,7 @@ void CGUIProfiler::updateDisplay()
{ {
for ( u32 i=0; i < Profiler->getProfileDataCount(); ++i ) for ( u32 i=0; i < Profiler->getProfileDataCount(); ++i )
{ {
const SProfileData& data = Profiler->getProfileDataByIndex(i); rowIndex = addDataToTable(rowIndex, i, groupIdx);
if ( data.getGroupIndex() == groupIdx
&& (!IgnoreUncalled || data.getCallsCounter() > 0) )
{
rowIndex = DisplayTable->addRow(rowIndex);
fillRow(rowIndex, data, false, false);
++rowIndex;
}
} }
} }
} }
...@@ -257,17 +264,6 @@ void CGUIProfiler::firstPage(bool includeOverview) ...@@ -257,17 +264,6 @@ void CGUIProfiler::firstPage(bool includeOverview)
CurrentGroupPage = 0; CurrentGroupPage = 0;
} }
void CGUIProfiler::setIgnoreUncalled(bool ignore)
{
IgnoreUncalled = ignore;
}
bool CGUIProfiler::getIgnoreUncalled() const
{
return IgnoreUncalled;
}
//! Sets another skin independent font. //! Sets another skin independent font.
void CGUIProfiler::setOverrideFont(IGUIFont* font) void CGUIProfiler::setOverrideFont(IGUIFont* font)
{ {
...@@ -320,6 +316,13 @@ bool CGUIProfiler::getFrozen() const ...@@ -320,6 +316,13 @@ bool CGUIProfiler::getFrozen() const
return Frozen; 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 gui
} // end namespace irr } // end namespace irr
......
...@@ -25,7 +25,7 @@ namespace gui ...@@ -25,7 +25,7 @@ namespace gui
{ {
public: public:
//! constructor //! 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 //! Show first page of profile data
virtual void firstPage(bool includeOverview) _IRR_OVERRIDE_; virtual void firstPage(bool includeOverview) _IRR_OVERRIDE_;
...@@ -43,15 +43,8 @@ namespace gui ...@@ -43,15 +43,8 @@ namespace gui
//! Can several groups be displayed per page? //! Can several groups be displayed per page?
virtual bool getShowGroupsTogether() const _IRR_OVERRIDE_; 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. //! 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) //! Gets the override font (if any)
virtual IGUIFont* getOverrideFont() const _IRR_OVERRIDE_; virtual IGUIFont* getOverrideFont() const _IRR_OVERRIDE_;
...@@ -72,6 +65,8 @@ namespace gui ...@@ -72,6 +65,8 @@ namespace gui
//! Are updates currently frozen //! Are updates currently frozen
virtual bool getFrozen() const _IRR_OVERRIDE_; 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_ virtual IGUIElement* getElementFromPoint(const core::position2d<s32>& point) _IRR_OVERRIDE_
{ {
...@@ -85,6 +80,7 @@ namespace gui ...@@ -85,6 +80,7 @@ namespace gui
void updateDisplay(); void updateDisplay();
void fillRow(u32 rowIndex, const SProfileData& data, bool overviewTitle, bool groupTitle); void fillRow(u32 rowIndex, const SProfileData& data, bool overviewTitle, bool groupTitle);
u32 addDataToTable(u32 rowIndex, u32 dataIndex, u32 groupIndex);
void rebuildColumns(); void rebuildColumns();
IProfiler * Profiler; IProfiler * Profiler;
...@@ -92,11 +88,14 @@ namespace gui ...@@ -92,11 +88,14 @@ namespace gui
irr::u32 CurrentGroupIdx; irr::u32 CurrentGroupIdx;
irr::s32 CurrentGroupPage; irr::s32 CurrentGroupPage;
irr::s32 NumGroupPages; irr::s32 NumGroupPages;
bool IgnoreUncalled;
bool DrawBackground; bool DrawBackground;
bool Frozen; bool Frozen;
bool UnfreezeOnce; bool UnfreezeOnce;
bool ShowGroupsTogether; bool ShowGroupsTogether;
irr::u32 MinCalls;
irr::u32 MinTimeSum;
irr::f32 MinTimeAverage;
irr::u32 MinTimeMax;
}; };
} // end namespace gui } // end namespace gui
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment