Merge revision 4795:4798 from trunk to ogl-es:

- Add examples 30+ to the buildAllExamples script.
- Rewrite profiler implementation some more to get around linker troubles.
- Remove superfluous if which always resulted in true. Thx @dcb for reporting (Bug #430).


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@4847 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2014-05-08 17:06:45 +00:00
parent c8fe2d4e3b
commit d6d4221eb0
21 changed files with 748 additions and 683 deletions

View File

@ -288,9 +288,23 @@ int main()
if (driverType==video::EDT_COUNT)
return 1;
/*
Profiler is independent of the device - so we can time the device setup
*/
MY_PROFILE(s32 pDev = getProfiler().add(L"createDevice", L"group a");)
MY_PROFILE(getProfiler().start(pDev);)
IrrlichtDevice * device = createDevice(driverType, core::dimension2d<u32>(640, 480));
if (device == 0)
{
/*
When working with start/stop you should add a stop to all exit paths.
Although in this case it wouldn't matter as we don't do anything with it when we quit here.
*/
MY_PROFILE(getProfiler().stop(pDev);)
return 1; // could not create selected driver.
}
MY_PROFILE(getProfiler().stop(pDev);)
video::IVideoDriver* driver = device->getVideoDriver();
IGUIEnvironment* env = device->getGUIEnvironment();

View File

@ -27,7 +27,7 @@
<Project filename="24.CursorControl/CursorControl.cbp" />
<Project filename="25.XmlHandling/XmlHandling.cbp" />
<Project filename="26.OcclusionQuery/OcclusionQuery.cbp" />
<Project filename="30.Profiling/Profiling.cbp" />
<Project filename="30.Profiling/Profiling.cbp" active="1" />
<Project filename="Demo/demo.cbp" />
<Project filename="../tools/GUIEditor/GUIEditor_gcc.cbp" />
<Project filename="../tools/MeshConverter/MeshConverter.cbp" />

View File

@ -1,7 +1,7 @@
#! /bin/bash
[ -z $1 ] || TARGET=$1
[ -z $TARGET ] && TARGET=all
for i in [012]* Demo; do
for i in [0123]* Demo; do
echo "Building $i";
pushd $i && make clean $TARGET;
popd;

View File

@ -2,23 +2,34 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
// Written by Michael Zeilfelder
#ifndef __PROFILER_H_INCLUDED__
#define __PROFILER_H_INCLUDED__
#ifndef __I_PROFILER_H_INCLUDED__
#define __I_PROFILER_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "irrString.h"
#include "irrArray.h"
#include "ITimer.h"
#include <limits.h> // for INT_MAX (we should have a S32_MAX...)
namespace irr
{
class ITimer;
//! For internal engine use:
//! Code inside IRR_PROFILE is only executed when _IRR_COMPILE_WITH_PROFILING_ is set
//! This allows disabling all profiler code completely by changing that define.
//! It's generally useful to wrap profiler-calls in application code with a similar macro.
#ifdef _IRR_COMPILE_WITH_PROFILING_
#define IRR_PROFILE(X) X
#else
#define IRR_PROFILE(X)
#endif // IRR_PROFILE
//! Used to store the profile data (and also used for profile group data).
struct SProfileData
{
friend class CProfiler;
friend class IProfiler;
SProfileData()
{
@ -66,16 +77,16 @@ struct SProfileData
private:
//! Convert the whole data into a string
core::stringw getAsString() const;
//! Return a string which describes the columns returned by getAsString
static core::stringw makeTitleString();
// just to be used for searching as it does no initialization besides id
SProfileData(u32 id) : Id(id) {}
void reset();
void reset()
{
CountCalls = 0;
LongestTime = 0;
TimeSum = 0;
LastTimeStarted = 0;
}
s32 Id;
u32 GroupIndex;
@ -95,13 +106,15 @@ private:
// And also why it works with id's instead of strings in the start/stop functions even if it makes using
// the class slightly harder.
// The class comes without reference-counting because the profiler-instance is never released (TBD).
class IRRLICHT_API CProfiler
class IProfiler
{
public:
//! Constructor. You could use this to create a new profiler, but usually getProfiler() is used to access the global instance.
CProfiler();
IProfiler() : Timer(0), NextAutoId(INT_MAX)
{}
~CProfiler();
virtual ~IProfiler()
{}
//! Add an id with given name and group which can be used for profiling with start/stop
/** After calling this once you can start/stop profiling for the given id.
@ -109,14 +122,14 @@ public:
have been added automatically by the other add function.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data. */
void add(s32 id, const core::stringw &name, const core::stringw &groupName);
inline void add(s32 id, const core::stringw &name, const core::stringw &groupName);
//! Add an automatically generated for the given name and group which can be used for profiling with start/stop.
/** After calling this once you can start/stop profiling with the returned id.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data.
\return Automatic id's start at INT_MAX and count down for each new id. If the name already has an id then that id will be returned. */
s32 add(const core::stringw &name, const core::stringw &groupName);
inline s32 add(const core::stringw &name, const core::stringw &groupName);
//! Return the number of profile data blocks. There is one for each id.
u32 getProfileDataCount() const
@ -128,7 +141,7 @@ public:
/** \param result Receives the resulting data index when one was found.
\param name String with name to search for
\return true when found, false when not found */
bool findDataIndex(u32 & result, const core::stringw &name) const;
inline bool findDataIndex(u32 & result, const core::stringw &name) const;
//! Get the profile data
/** \param index A value between 0 and getProfileDataCount()-1. Indices can change when new id's are added.*/
@ -140,25 +153,18 @@ public:
//! Get the profile data
/** \param id Same value as used in ::add
\return Profile data for the given id or 0 when it does not exist. */
const SProfileData* getProfileDataById(u32 id)
{
SProfileData data(id);
s32 idx = ProfileDatas.binary_search(data);
if ( idx >= 0 )
return &ProfileDatas[idx];
return NULL;
}
inline const SProfileData* getProfileDataById(u32 id);
//! Get the number of profile groups. Will be at least 1.
/** NOTE: The first groups is always L"overview" which is an overview for all existing groups */
u32 getGroupCount() const
inline u32 getGroupCount() const
{
return ProfileGroups.size();
}
//! Get profile data for a group.
/** NOTE: The first groups is always L"overview" which is an overview for all existing groups */
const SProfileData& getGroupData(u32 index) const
inline const SProfileData& getGroupData(u32 index) const
{
return ProfileGroups[index];
}
@ -167,7 +173,7 @@ public:
/** \param result Receives the resulting group index when one was found.
\param name String with name to search for
\return true when found, false when not found */
bool findGroupIndex(u32 & result, const core::stringw &name) const;
inline bool findGroupIndex(u32 & result, const core::stringw &name) const;
//! Start profile-timing for the given id
@ -179,41 +185,103 @@ public:
inline void stop(s32 id);
//! Reset profile data for the given id
void resetDataById(s32 id);
inline void resetDataById(s32 id);
//! Reset profile data for the given index
void resetDataByIndex(u32 index);
inline void resetDataByIndex(u32 index);
//! Reset profile data for a whole group
void resetGroup(u32 index);
inline void resetGroup(u32 index);
//! Reset all profile data
/** NOTE: This is not deleting id's or groups, just resetting all timers to 0. */
void resetAll();
inline void resetAll();
//! Write all profile-data into a string
/** \param result Receives the result string.
\param includeOverview When true a group-overview is attached first
\param suppressUncalled When true elements which got never called are not printed */
void printAll(core::stringw &result, bool includeOverview=false,bool suppressUncalled=true) const;
virtual void printAll(core::stringw &result, bool includeOverview=false,bool suppressUncalled=true) const = 0;
//! Write the profile data of one group into a string
/** \param result Receives the result string.
\param groupIndex_ */
void printGroup(core::stringw &result, u32 groupIndex, bool suppressUncalled) const;
virtual void printGroup(core::stringw &result, u32 groupIndex, bool suppressUncalled) const = 0;
protected:
u32 addGroup(const core::stringw &name);
inline u32 addGroup(const core::stringw &name);
private:
ITimer * Timer; // I would prefer using os::Timer, but os.h is not in the public interface so far.
s32 NextAutoId; // for giving out id's automatically
// I would prefer using os::Timer, but os.h is not in the public interface so far.
// Timer must be initialized by the implementation.
ITimer * Timer;
core::array<SProfileData> ProfileDatas;
core::array<SProfileData> ProfileGroups;
private:
s32 NextAutoId; // for giving out id's automatically
};
void CProfiler::start(s32 id)
//! Access the Irrlicht profiler object.
/** Profiler is always accessible, except in destruction of global objects.
If you want to get internal profiling information about the engine itself
you will have to re-compile the engine with _IRR_COMPILE_WITH_PROFILING_ enabled.
But you can use the profiler for profiling your own projects without that. */
IRRLICHT_API IProfiler& IRRCALLCONV getProfiler();
//! Class where the objects profile their own life-time.
/** This is a comfort wrapper around the IProfiler start/stop mechanism which is easier to use
when you want to profile a scope. You only have to create an object and it will profile it's own lifetime
for the given id. */
class CProfileScope
{
public:
//! Construct with an known id.
/** This is the fastest scope constructor, but the id must have been added before.
\param id Any id which you did add to the profiler before. */
CProfileScope(s32 id)
: Id(id), Profiler(getProfiler())
{
Profiler.start(Id);
}
//! Object will create the given name, groupName combination for the id if it doesn't exist already
/** \param id: Should be >= 0 as negative id's are reserved for Irrlicht. Also very large numbers (near INT_MAX) might
have been created already by the automatic add function of ::IProfiler.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data. */
CProfileScope(s32 id, const core::stringw &name, const core::stringw &groupName)
: Id(id), Profiler(getProfiler())
{
Profiler.add(Id, name, groupName);
Profiler.start(Id);
}
//! Object will create an id for the given name, groupName combination if they don't exist already
/** Slowest scope constructor, but usually still fine unless speed is very critical.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data. */
CProfileScope(const core::stringw &name, const core::stringw &groupName)
: Profiler(getProfiler())
{
Id = Profiler.add(name, groupName);
Profiler.start(Id);
}
~CProfileScope()
{
Profiler.stop(Id);
}
protected:
s32 Id;
IProfiler& Profiler;
};
// IMPLEMENTATION for in-line stuff
void IProfiler::start(s32 id)
{
s32 idx = ProfileDatas.binary_search(SProfileData(id));
if ( idx >= 0 && Timer )
@ -222,7 +290,7 @@ void CProfiler::start(s32 id)
}
}
void CProfiler::stop(s32 id)
void IProfiler::stop(s32 id)
{
if ( Timer )
{
@ -253,71 +321,145 @@ void CProfiler::stop(s32 id)
}
}
//! Access the Irrlicht profiler object.
/** Profiler is always accessible, except in destruction of global objects.
If you want to get internal profiling information about the engine itself
you will have to re-compile the engine with _IRR_COMPILE_WITH_PROFILING_ enabled.
But you can use the profiler for profiling your own projects without that. */
IRRLICHT_API CProfiler& IRRCALLCONV getProfiler();
//! Class where the objects profile their own life-time.
/** This is a comfort wrapper around the CProfiler start/stop mechanism which is easier to use
when you want to profile a scope. You only have to create an object and it will profile it's own lifetime
for the given id. */
class CProfileScope
s32 IProfiler::add(const core::stringw &name, const core::stringw &groupName)
{
public:
//! Construct with an known id.
/** This is the fastest scope constructor, but the id must have been added before.
\param id Any id which you did add to the profiler before. */
CProfileScope(s32 id)
: Id(id), Profiler(getProfiler())
u32 index;
if ( findDataIndex(index, name) )
{
Profiler.start(Id);
add( ProfileDatas[index].Id, name, groupName );
return ProfileDatas[index].Id;
}
else
{
s32 id = NextAutoId;
--NextAutoId;
add( id, name, groupName );
return id;
}
}
void IProfiler::add(s32 id, const core::stringw &name, const core::stringw &groupName)
{
u32 groupIdx;
if ( !findGroupIndex(groupIdx, groupName) )
{
groupIdx = addGroup(groupName);
}
//! Object will create the given name, groupName combination for the id if it doesn't exist already
/** \param id: Should be >= 0 as negative id's are reserved for Irrlicht. Also very large numbers (near INT_MAX) might
have been created already by the automatic add function of ::CProfiler.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data. */
CProfileScope(s32 id, const core::stringw &name, const core::stringw &groupName)
: Id(id), Profiler(getProfiler())
SProfileData data(id);
s32 idx = ProfileDatas.binary_search(data);
if ( idx < 0 )
{
Profiler.add(Id, name, groupName);
Profiler.start(Id);
data.reset();
data.GroupIndex = groupIdx;
data.Name = name;
ProfileDatas.push_back(data);
ProfileDatas.sort();
}
else
{
// only reset on group changes, otherwise we want to keep the data or coding CProfileScope would become tricky.
if ( groupIdx != ProfileDatas[idx].GroupIndex )
{
resetDataByIndex((u32)idx);
ProfileDatas[idx].GroupIndex = groupIdx;
}
ProfileDatas[idx].Name = name;
}
}
u32 IProfiler::addGroup(const core::stringw &name)
{
SProfileData group;
group.Id = -1; // Id for groups doesn't matter so far
group.Name = name;
ProfileGroups.push_back(group);
return ProfileGroups.size()-1;
}
bool IProfiler::findDataIndex(u32 & result, const core::stringw &name) const
{
for ( u32 i=0; i < ProfileDatas.size(); ++i )
{
if ( ProfileDatas[i].Name == name )
{
result = i;
return true;
}
}
//! Object will create an id for the given name, groupName combination if they don't exist already
/** Slowest scope constructor, but usually still fine unless speed is very critical.
\param name: Name for displaying profile data.
\param groupName: Each id belongs into a group - this helps on displaying profile data. */
CProfileScope(const core::stringw &name, const core::stringw &groupName)
: Profiler(getProfiler())
return false;
}
const SProfileData* IProfiler::getProfileDataById(u32 id)
{
SProfileData data(id);
s32 idx = ProfileDatas.binary_search(data);
if ( idx >= 0 )
return &ProfileDatas[idx];
return NULL;
}
bool IProfiler::findGroupIndex(u32 & result, const core::stringw &name) const
{
for ( u32 i=0; i < ProfileGroups.size(); ++i )
{
Id = Profiler.add(name, groupName);
Profiler.start(Id);
if ( ProfileGroups[i].Name == name )
{
result = i;
return true;
}
}
~CProfileScope()
{
Profiler.stop(Id);
}
return false;
}
void IProfiler::resetDataById(s32 id)
{
s32 idx = ProfileDatas.binary_search(SProfileData(id));
if ( idx >= 0 )
{
resetDataByIndex((u32)idx);
}
}
void IProfiler::resetDataByIndex(u32 index)
{
SProfileData &data = ProfileDatas[index];
SProfileData & group = ProfileGroups[data.GroupIndex];
group.CountCalls -= data.CountCalls;
group.TimeSum -= data.TimeSum;
data.reset();
}
//! Reset profile data for a whole group
void IProfiler::resetGroup(u32 index)
{
for ( u32 i=0; i<ProfileDatas.size(); ++i )
{
if ( ProfileDatas[i].GroupIndex == index )
ProfileDatas[i].reset();
}
if ( index < ProfileGroups.size() )
ProfileGroups[index].reset();
}
void IProfiler::resetAll()
{
for ( u32 i=0; i<ProfileDatas.size(); ++i )
{
ProfileDatas[i].reset();
}
for ( u32 i=0; i<ProfileGroups.size(); ++i )
{
ProfileGroups[i].reset();
}
}
protected:
s32 Id;
CProfiler& Profiler;
};
} // namespace irr
//! For internal engine use:
//! Code inside IRR_PROFILE is only executed when _IRR_COMPILE_WITH_PROFILING_ is set
//! This allows disabling all profiler code completely by changing that define.
//! It's generally useful to wrap profiler-calls in application code with a similar macro.
#ifdef _IRR_COMPILE_WITH_PROFILING_
#define IRR_PROFILE(X) X
#else
#define IRR_PROFILE(X)
#endif // IRR_PROFILE
#endif // __PROFILER_H_INCLUDED__
#endif // __I_PROFILER_H_INCLUDED__

View File

@ -36,7 +36,7 @@
#include "CMeshBuffer.h"
#include "coreutil.h"
#include "CVertexBuffer.h"
#include "CProfiler.h"
#include "IProfiler.h"
#include "dimension2d.h"
#include "ECullingTypes.h"
#include "EDebugSceneTypes.h"

View File

@ -13,7 +13,7 @@
namespace irr
{
class CProfiler;
class IProfiler;
struct SProfileData;
namespace gui
@ -66,7 +66,7 @@ namespace gui
void fillRow(u32 rowIndex, const SProfileData& data, bool overviewTitle, bool groupTitle);
void rebuildColumns();
CProfiler * Profiler;
IProfiler * Profiler;
irr::gui::IGUITable* DisplayTable;
irr::u32 CurrentGroupIdx;
bool IgnoreUncalled;

View File

@ -272,13 +272,10 @@ void CIrrMeshWriter::writeMeshBuffer(const scene::IMeshBuffer* buffer)
Writer->writeText(str.c_str());
}
if (i % maxIndicesPerLine != maxIndicesPerLine)
{
if (i % maxIndicesPerLine == maxIndicesPerLine-1)
Writer->writeLineBreak();
else
Writer->writeText(L" ");
}
if (i % maxIndicesPerLine == maxIndicesPerLine-1)
Writer->writeLineBreak();
else
Writer->writeText(L" ");
}
if ((indexCount-1) % maxIndicesPerLine != maxIndicesPerLine-1)

View File

@ -13,7 +13,7 @@
#include "os.h"
#include "CShadowVolumeSceneNode.h"
#include "EProfileIDs.h"
#include "CProfiler.h"
#include "IProfiler.h"
namespace irr
{

View File

@ -4,63 +4,16 @@
#include "CProfiler.h"
#include "CTimer.h"
#include <limits.h>
namespace irr
{
IRRLICHT_API CProfiler& IRRCALLCONV getProfiler()
IRRLICHT_API IProfiler& IRRCALLCONV getProfiler()
{
static CProfiler profiler;
return profiler;
}
//! Convert the whole data into a string
core::stringw SProfileData::getAsString() const
{
if ( CountCalls > 0 )
{
#ifdef _MSC_VER
#pragma warning(disable:4996) // 'sprintf' was declared deprecated
#endif
// Can't use swprintf as it fails on some platforms (especially mobile platforms)
// Can't use Irrlicht functions because we have no string formatting.
char dummy[1023];
sprintf(dummy, "%-15.15s%-12u%-12u%-12u%-12u",
core::stringc(Name).c_str(), CountCalls, TimeSum,
TimeSum / CountCalls, LongestTime);
dummy[1022] = 0;
return core::stringw(dummy);
#ifdef _MSC_VER
#pragma warning(default :4996) // 'sprintf' was declared deprecated
#endif
}
else
{
return Name;
}
}
//! Return a string which describes the columns returned by getAsString
core::stringw SProfileData::makeTitleString()
{
return core::stringw("name calls time(sum) time(avg) time(max)");
}
void SProfileData::reset()
{
CountCalls = 0;
LongestTime = 0;
TimeSum = 0;
LastTimeStarted = 0;
}
CProfiler::CProfiler()
: Timer(0)
, NextAutoId(INT_MAX)
{
Timer = new CTimer(true);
@ -73,139 +26,9 @@ CProfiler::~CProfiler()
Timer->drop();
}
s32 CProfiler::add(const core::stringw &name, const core::stringw &groupName)
{
u32 index;
if ( findDataIndex(index, name) )
{
add( ProfileDatas[index].Id, name, groupName );
return ProfileDatas[index].Id;
}
else
{
s32 id = NextAutoId;
--NextAutoId;
add( id, name, groupName );
return id;
}
}
void CProfiler::add(s32 id, const core::stringw &name, const core::stringw &groupName)
{
u32 groupIdx;
if ( !findGroupIndex(groupIdx, groupName) )
{
groupIdx = addGroup(groupName);
}
SProfileData data(id);
s32 idx = ProfileDatas.binary_search(data);
if ( idx < 0 )
{
data.reset();
data.GroupIndex = groupIdx;
data.Name = name;
ProfileDatas.push_back(data);
ProfileDatas.sort();
}
else
{
// only reset on group changes, otherwise we want to keep the data or coding CProfileScope would become tricky.
if ( groupIdx != ProfileDatas[idx].GroupIndex )
{
resetDataByIndex((u32)idx);
ProfileDatas[idx].GroupIndex = groupIdx;
}
ProfileDatas[idx].Name = name;
}
}
u32 CProfiler::addGroup(const core::stringw &name)
{
SProfileData group;
group.Id = -1; // Id for groups doesn't matter so far
group.Name = name;
ProfileGroups.push_back(group);
return ProfileGroups.size()-1;
}
bool CProfiler::findDataIndex(u32 & result, const core::stringw &name) const
{
for ( u32 i=0; i < ProfileDatas.size(); ++i )
{
if ( ProfileDatas[i].Name == name )
{
result = i;
return true;
}
}
return false;
}
bool CProfiler::findGroupIndex(u32 & result, const core::stringw &name) const
{
for ( u32 i=0; i < ProfileGroups.size(); ++i )
{
if ( ProfileGroups[i].Name == name )
{
result = i;
return true;
}
}
return false;
}
void CProfiler::resetDataById(s32 id)
{
s32 idx = ProfileDatas.binary_search(SProfileData(id));
if ( idx >= 0 )
{
resetDataByIndex((u32)idx);
}
}
void CProfiler::resetDataByIndex(u32 index)
{
SProfileData &data = ProfileDatas[index];
SProfileData & group = ProfileGroups[data.GroupIndex];
group.CountCalls -= data.CountCalls;
group.TimeSum -= data.TimeSum;
data.reset();
}
//! Reset profile data for a whole group
void CProfiler::resetGroup(u32 index)
{
for ( u32 i=0; i<ProfileDatas.size(); ++i )
{
if ( ProfileDatas[i].GroupIndex == index )
ProfileDatas[i].reset();
}
if ( index < ProfileGroups.size() )
ProfileGroups[index].reset();
}
void CProfiler::resetAll()
{
for ( u32 i=0; i<ProfileDatas.size(); ++i )
{
ProfileDatas[i].reset();
}
for ( u32 i=0; i<ProfileGroups.size(); ++i )
{
ProfileGroups[i].reset();
}
}
void CProfiler::printAll(core::stringw &ostream, bool includeOverview, bool suppressUncalled) const
{
ostream += SProfileData::makeTitleString();
ostream += makeTitleString();
ostream += L"\n";
for ( u32 i=includeOverview ?0:1; i<ProfileGroups.size(); ++i )
{
@ -215,7 +38,7 @@ void CProfiler::printAll(core::stringw &ostream, bool includeOverview, bool supp
void CProfiler::printGroup(core::stringw &ostream, u32 idxGroup, bool suppressUncalled) const
{
ostream += ProfileGroups[idxGroup].getAsString();
ostream += getAsString(ProfileGroups[idxGroup]);
ostream += L"\n";
// print overview for groups
@ -223,9 +46,9 @@ void CProfiler::printGroup(core::stringw &ostream, u32 idxGroup, bool suppressUn
{
for ( u32 i=0; i<ProfileGroups.size(); ++i )
{
if ( !suppressUncalled || ProfileGroups[i].CountCalls > 0)
if ( !suppressUncalled || ProfileGroups[i].getCallsCounter() > 0)
{
ostream += ProfileGroups[i].getAsString();
ostream += getAsString(ProfileGroups[i]);
ostream += L"\n";
}
}
@ -235,14 +58,47 @@ void CProfiler::printGroup(core::stringw &ostream, u32 idxGroup, bool suppressUn
{
for ( u32 i=0; i<ProfileDatas.size(); ++i )
{
if ( (!suppressUncalled || ProfileDatas[i].CountCalls > 0)
&& ProfileDatas[i].GroupIndex == idxGroup )
if ( (!suppressUncalled || ProfileDatas[i].getCallsCounter() > 0)
&& ProfileDatas[i].getGroupIndex() == idxGroup )
{
ostream += ProfileDatas[i].getAsString();
ostream += getAsString(ProfileDatas[i]);
ostream += L"\n";
}
}
}
}
//! Convert the whole data into a string
core::stringw CProfiler::getAsString(const SProfileData& data) const
{
if ( data.getCallsCounter() > 0 )
{
#ifdef _MSC_VER
#pragma warning(disable:4996) // 'sprintf' was declared deprecated
#endif
// Can't use swprintf as it fails on some platforms (especially mobile platforms)
// Can't use Irrlicht functions because we have no string formatting.
char dummy[1023];
sprintf(dummy, "%-15.15s%-12u%-12u%-12u%-12u",
core::stringc(data.getName()).c_str(), data.getCallsCounter(), data.getTimeSum(),
data.getTimeSum() / data.getCallsCounter(), data.getLongestTime());
dummy[1022] = 0;
return core::stringw(dummy);
#ifdef _MSC_VER
#pragma warning(default :4996) // 'sprintf' was declared deprecated
#endif
}
else
{
return data.getName();
}
}
//! Return a string which describes the columns returned by getAsString
core::stringw CProfiler::makeTitleString() const
{
return core::stringw("name calls time(sum) time(avg) time(max)");
}
} // namespace irr

View File

@ -0,0 +1,32 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// Written by Michael Zeilfelder
#ifndef __C_PROFILER_H_INCLUDED__
#define __C_PROFILER_H_INCLUDED__
#include "IrrCompileConfig.h"
#include "IProfiler.h"
namespace irr
{
class CProfiler : public IProfiler
{
public:
CProfiler();
virtual ~CProfiler();
//! Write all profile-data into a string
virtual void printAll(core::stringw &result, bool includeOverview,bool suppressUncalled) const _IRR_OVERRIDE_;
//! Write the profile data of one group into a string
virtual void printGroup(core::stringw &result, u32 groupIndex, bool suppressUncalled) const _IRR_OVERRIDE_;
protected:
core::stringw makeTitleString() const;
core::stringw getAsString(const SProfileData& data) const;
};
} // namespace irr
#endif // __C_PROFILER_H_INCLUDED__

View File

@ -16,7 +16,7 @@
#include "IWriteFile.h"
#include "ISceneLoader.h"
#include "EProfileIDs.h"
#include "CProfiler.h"
#include "IProfiler.h"
#include "os.h"

File diff suppressed because it is too large Load Diff

View File

@ -838,9 +838,9 @@
<ClInclude Include="..\..\include\IAnimatedMeshMD3.h" />
<ClInclude Include="..\..\include\IContextManager.h" />
<ClInclude Include="..\..\include\IEventReceiver.h" />
<ClInclude Include="..\..\include\CProfiler.h" />
<ClInclude Include="..\..\include\ILogger.h" />
<ClInclude Include="..\..\include\IOSOperator.h" />
<ClInclude Include="..\..\include\IProfiler.h" />
<ClInclude Include="..\..\include\IRandomizer.h" />
<ClInclude Include="..\..\include\IReferenceCounted.h" />
<ClInclude Include="..\..\include\IrrCompileConfig.h" />
@ -923,7 +923,7 @@
<ClInclude Include="..\..\include\IMeshLoader.h" />
<ClInclude Include="..\..\include\IMeshManipulator.h" />
<ClInclude Include="..\..\include\IMeshSceneNode.h" />
<ClInclude Include="..\..\include\IMeshTextureLoader.h" />
<ClInclude Include="..\..\include\IMeshTextureLoader.h" />
<ClInclude Include="..\..\include\IMeshWriter.h" />
<ClInclude Include="..\..\include\IMetaTriangleSelector.h" />
<ClInclude Include="..\..\include\IParticleAffector.h" />
@ -969,7 +969,7 @@
<ClInclude Include="..\..\include\EGUIAlignment.h" />
<ClInclude Include="..\..\include\EGUIElementTypes.h" />
<ClInclude Include="..\..\include\EMessageBoxFlags.h" />
<ClInclude Include="..\..\include\EFocusFlags.h" />
<ClInclude Include="..\..\include\EFocusFlags.h" />
<ClInclude Include="..\..\include\ICursorControl.h" />
<ClInclude Include="..\..\include\IGUIButton.h" />
<ClInclude Include="..\..\include\IGUICheckbox.h" />
@ -986,7 +986,7 @@
<ClInclude Include="..\..\include\IGUIInOutFader.h" />
<ClInclude Include="..\..\include\IGUIListBox.h" />
<ClInclude Include="..\..\include\IGUIMeshViewer.h" />
<ClInclude Include="..\..\include\IGUIProfiler.h" />
<ClInclude Include="..\..\include\IGUIProfiler.h" />
<ClInclude Include="..\..\include\IGUIScrollBar.h" />
<ClInclude Include="..\..\include\IGUISkin.h" />
<ClInclude Include="..\..\include\IGUISpinBox.h" />
@ -1017,6 +1017,7 @@
<ClInclude Include="COGLESExtensionHandler.h" />
<ClInclude Include="COGLESMaterialRenderer.h" />
<ClInclude Include="COGLESTexture.h" />
<ClInclude Include="CProfiler.h" />
<ClInclude Include="CSceneManager.h" />
<ClInclude Include="CWGLManager.h" />
<ClInclude Include="Octree.h" />
@ -1035,7 +1036,7 @@
<ClInclude Include="CLWOMeshFileLoader.h" />
<ClInclude Include="CMD2MeshFileLoader.h" />
<ClInclude Include="CMD3MeshFileLoader.h" />
<ClInclude Include="CMeshTextureLoader.h" />
<ClInclude Include="CMeshTextureLoader.h" />
<ClInclude Include="CMS3DMeshFileLoader.h" />
<ClInclude Include="CMY3DHelper.h" />
<ClInclude Include="CMY3DMeshFileLoader.h" />
@ -1168,7 +1169,7 @@
<ClInclude Include="COSOperator.h" />
<ClInclude Include="CTimer.h" />
<ClInclude Include="os.h" />
<ClInclude Include="EProfileIDs.h" />
<ClInclude Include="EProfileIDs.h" />
<ClInclude Include="lzma\LzmaDec.h" />
<ClInclude Include="lzma\Types.h" />
<ClInclude Include="zlib\crc32.h" />
@ -1247,7 +1248,7 @@
<ClInclude Include="CGUIMessageBox.h" />
<ClInclude Include="CGUIModalScreen.h" />
<ClInclude Include="CGUIProfiler.h" />
<ClInclude Include="CGUIScrollBar.h" />
<ClInclude Include="CGUIScrollBar.h" />
<ClInclude Include="CGUISkin.h" />
<ClInclude Include="CGUISpinBox.h" />
<ClInclude Include="CGUISpriteBank.h" />
@ -1300,7 +1301,7 @@
<ClCompile Include="CLWOMeshFileLoader.cpp" />
<ClCompile Include="CMD2MeshFileLoader.cpp" />
<ClCompile Include="CMD3MeshFileLoader.cpp" />
<ClCompile Include="CMeshTextureLoader.cpp" />
<ClCompile Include="CMeshTextureLoader.cpp" />
<ClCompile Include="CMS3DMeshFileLoader.cpp" />
<ClCompile Include="CMY3DMeshFileLoader.cpp" />
<ClCompile Include="COBJMeshFileLoader.cpp" />
@ -1448,7 +1449,7 @@
<ClCompile Include="Irrlicht.cpp" />
<ClCompile Include="leakHunter.cpp" />
<ClCompile Include="os.cpp" />
<ClCompile Include="CProfiler.cpp" />
<ClCompile Include="CProfiler.cpp" />
<ClCompile Include="lzma\LzmaDec.c" />
<ClCompile Include="zlib\adler32.c" />
<ClCompile Include="zlib\compress.c" />
@ -1579,7 +1580,7 @@
<ClCompile Include="CGUIMessageBox.cpp" />
<ClCompile Include="CGUIModalScreen.cpp" />
<ClCompile Include="CGUIProfiler.cpp" />
<ClCompile Include="CGUIScrollBar.cpp" />
<ClCompile Include="CGUIScrollBar.cpp" />
<ClCompile Include="CGUISkin.cpp" />
<ClCompile Include="CGUISpinBox.cpp" />
<ClCompile Include="CGUISpriteBank.cpp" />

View File

@ -111,10 +111,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\IEventReceiver.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="..\..\include\CProfiler.h">
<ClInclude Include="..\..\include\IEventReceiver.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ILogger.h">
@ -363,7 +360,7 @@
<ClInclude Include="..\..\include\IMeshSceneNode.h">
<Filter>include\scene</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IMeshTextureLoader.h">
<ClInclude Include="..\..\include\IMeshTextureLoader.h">
<Filter>include\scene</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IMeshWriter.h">
@ -498,7 +495,7 @@
<ClInclude Include="..\..\include\EMessageBoxFlags.h">
<Filter>include\gui</Filter>
</ClInclude>
<ClInclude Include="..\..\include\EFocusFlags.h">
<ClInclude Include="..\..\include\EFocusFlags.h">
<Filter>include\gui</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ICursorControl.h">
@ -549,7 +546,7 @@
<ClInclude Include="..\..\include\IGUIMeshViewer.h">
<Filter>include\gui</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IGUIProfiler.h">
<ClInclude Include="..\..\include\IGUIProfiler.h">
<Filter>include\gui</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IGUIScrollBar.h">
@ -642,7 +639,7 @@
<ClInclude Include="CMD3MeshFileLoader.h">
<Filter>Irrlicht\scene\loaders</Filter>
</ClInclude>
<ClInclude Include="CMeshTextureLoader.h">
<ClInclude Include="CMeshTextureLoader.h">
<Filter>Irrlicht\scene\loaders</Filter>
</ClInclude>
<ClInclude Include="CMS3DMeshFileLoader.h">
@ -1035,7 +1032,7 @@
<ClInclude Include="os.h">
<Filter>Irrlicht\irr</Filter>
</ClInclude>
<ClInclude Include="EProfileIDs.h">
<ClInclude Include="EProfileIDs.h">
<Filter>Irrlicht\irr</Filter>
</ClInclude>
<ClInclude Include="lzma\LzmaDec.h">
@ -1272,7 +1269,7 @@
<ClInclude Include="CGUIProfiler.h">
<Filter>Irrlicht\gui</Filter>
</ClInclude>
<ClInclude Include="CGUIScrollBar.h">
<ClInclude Include="CGUIScrollBar.h">
<Filter>Irrlicht\gui</Filter>
</ClInclude>
<ClInclude Include="CGUISkin.h">
@ -1384,6 +1381,12 @@
<ClInclude Include="..\..\include\IContextManager.h">
<Filter>include\video</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IProfiler.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="CProfiler.h">
<Filter>Irrlicht\irr</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\changes.txt">
@ -1454,7 +1457,7 @@
<ClCompile Include="CMD3MeshFileLoader.cpp">
<Filter>Irrlicht\scene\loaders</Filter>
</ClCompile>
<ClCompile Include="CMeshTextureLoader.cpp">
<ClCompile Include="CMeshTextureLoader.cpp">
<Filter>Irrlicht\scene\loaders</Filter>
</ClCompile>
<ClCompile Include="CMS3DMeshFileLoader.cpp">
@ -1889,7 +1892,7 @@
<ClCompile Include="os.cpp">
<Filter>Irrlicht\irr</Filter>
</ClCompile>
<ClCompile Include="CProfiler.cpp">
<ClCompile Include="CProfiler.cpp">
<Filter>Irrlicht\irr</Filter>
</ClCompile>
<ClCompile Include="lzma\LzmaDec.c">
@ -2282,7 +2285,7 @@
<ClCompile Include="CGUIProfiler.cpp">
<Filter>Irrlicht\gui</Filter>
</ClCompile>
<ClCompile Include="CGUIScrollBar.cpp">
<ClCompile Include="CGUIScrollBar.cpp">
<Filter>Irrlicht\gui</Filter>
</ClCompile>
<ClCompile Include="CGUISkin.cpp">

View File

@ -842,7 +842,7 @@
<ClInclude Include="..\..\include\EMaterialFlags.h" />
<ClInclude Include="..\..\include\IAnimatedMeshMD3.h" />
<ClInclude Include="..\..\include\IEventReceiver.h" />
<ClInclude Include="..\..\include\CProfiler.h" />
<ClInclude Include="..\..\include\IProfiler.h" />
<ClInclude Include="..\..\include\ILogger.h" />
<ClInclude Include="..\..\include\IOSOperator.h" />
<ClInclude Include="..\..\include\IRandomizer.h" />
@ -1173,6 +1173,7 @@
<ClInclude Include="COSOperator.h" />
<ClInclude Include="CTimer.h" />
<ClInclude Include="os.h" />
<ClInclude Include="CProfiler.h" />
<ClInclude Include="EProfileIDs.h" />
<ClInclude Include="lzma\LzmaDec.h" />
<ClInclude Include="lzma\Types.h" />

View File

@ -114,7 +114,7 @@
<ClInclude Include="..\..\include\IEventReceiver.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="..\..\include\CProfiler.h">
<ClInclude Include="..\..\include\IProfiler.h">
<Filter>include</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ILogger.h">
@ -1037,6 +1037,9 @@
</ClInclude>
<ClInclude Include="os.h">
<Filter>Irrlicht\irr</Filter>
</ClInclude>
<ClInclude Include="CProfiler.h">
<Filter>Irrlicht\irr</Filter>
</ClInclude>
<ClInclude Include="EProfileIDs.h">
<Filter>Irrlicht\irr</Filter>

View File

@ -587,7 +587,7 @@
>
</File>
<File
RelativePath=".\..\..\include\CProfiler.h"
RelativePath=".\..\..\include\IProfiler.h"
>
</File>
<File
@ -3037,6 +3037,10 @@
RelativePath="CProfiler.cpp"
>
</File>
<File
RelativePath="CProfiler.h"
>
</File>
<File
RelativePath="EProfileIDs.h"
>

View File

@ -686,7 +686,7 @@
>
</File>
<File
RelativePath="..\..\include\CProfiler.h"
RelativePath="..\..\include\IProfiler.h"
>
</File>
<File
@ -2876,6 +2876,10 @@
RelativePath="CProfiler.cpp"
>
</File>
<File
RelativePath="CProfiler.h"
>
</File>
<File
RelativePath="EProfileIDs.h"
>

View File

@ -330,7 +330,7 @@
>
</File>
<File
RelativePath="..\..\include\CProfiler.h"
RelativePath="..\..\include\IProfiler.h"
>
</File>
<File
@ -2594,6 +2594,10 @@
RelativePath="CProfiler.cpp"
>
</File>
<File
RelativePath="CProfiler.h"
>
</File>
<File
RelativePath="EProfileIDs.h"
>

View File

@ -310,7 +310,7 @@
RelativePath="..\..\include\IEventReceiver.h">
</File>
<File
RelativePath="..\..\include\CProfiler.h">
RelativePath="..\..\include\IProfiler.h">
</File>
<File
RelativePath="..\..\include\IFileArchive.h">
@ -1443,6 +1443,9 @@
<File
RelativePath=".\CProfiler.cpp">
</File>
<File
RelativePath=".\CProfiler.h">
</File>
<File
RelativePath=".\EProfileIDs.h">
</File>

View File

@ -376,7 +376,7 @@ if "osx" in env["platform"] :
# sources of the examples
srcexamples = ["01.HelloWorld", "02.Quake3Map", "03.CustomSceneNode", "04.Movement", "05.UserInterface", "06.2DGraphics", "07.Collision", "08.SpecialFX", "09.Meshviewer", "10.Shaders", "11.PerPixelLighting", "12.TerrainRendering", "13.RenderToTexture", "15.LoadIrrFile", "16.Quake3MapShader", "17.HelloWorld_Mobile", "18.SplitScreen", "19.MouseAndJoystick", "20.ManagedLights", "22.MaterialViewer", "23.SMeshHandling", "24.CursorControl", "25.XmlHandling", "26.OcclusionQuery"]
srcexamples = ["01.HelloWorld", "02.Quake3Map", "03.CustomSceneNode", "04.Movement", "05.UserInterface", "06.2DGraphics", "07.Collision", "08.SpecialFX", "09.Meshviewer", "10.Shaders", "11.PerPixelLighting", "12.TerrainRendering", "13.RenderToTexture", "15.LoadIrrFile", "16.Quake3MapShader", "17.HelloWorld_Mobile", "18.SplitScreen", "19.MouseAndJoystick", "20.ManagedLights", "22.MaterialViewer", "23.SMeshHandling", "24.CursorControl", "25.XmlHandling", "26.OcclusionQuery", "30.Profiling"]
if "win" in env["platform"] :
srcexamples.append("14.Win32Window")
# ===================================================================================================================