mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3463 from ricardoquesada/perf_test_invocation
Adds 2 new performance tests
This commit is contained in:
commit
bbbfc82541
|
@ -125,7 +125,7 @@ const char* ProfilingTimer::description() const
|
|||
{
|
||||
static char s_desciption[512] = {0};
|
||||
|
||||
sprintf(s_desciption, "%s ::\tavg1: %dµ,\tavg2: %dµ,\tmin: %dµ,\tmax: %dµ,\ttotal: %.4fs,\tnr calls: %d", _nameStr.c_str(), _averageTime1, _averageTime2, minTime, maxTime, totalTime/1000000., numberOfCalls);
|
||||
sprintf(s_desciption, "%s ::\tavg1: %dµ,\tavg2: %dµ,\tmin: %dµ,\tmax: %dµ,\ttotal: %.2fs,\tnr calls: %d", _nameStr.c_str(), _averageTime1, _averageTime2, minTime, maxTime, totalTime/1000000., numberOfCalls);
|
||||
return s_desciption;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "PerformanceNodeChildrenTest.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
// Enable profiles for this file
|
||||
#undef CC_PROFILER_DISPLAY_TIMERS
|
||||
#define CC_PROFILER_DISPLAY_TIMERS() Profiler::getInstance()->displayTimers()
|
||||
|
@ -33,6 +35,9 @@ static std::function<NodeChildrenMainScene*()> createFunctions[] =
|
|||
CL(IterateSpriteSheetCArray),
|
||||
CL(IterateSpriteSheetIterator),
|
||||
|
||||
CL(CallFuncsSpriteSheetForEach),
|
||||
CL(CallFuncsSpriteSheetCMacro),
|
||||
|
||||
CL(AddSpriteSheet),
|
||||
CL(RemoveSpriteSheet),
|
||||
CL(ReorderSpriteSheet),
|
||||
|
@ -364,7 +369,78 @@ const char* IterateSpriteSheetIterator::profilerName()
|
|||
return "Iterator: begin(), end()";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// CallFuncsSpriteSheetForEach
|
||||
//
|
||||
////////////////////////////////////////////////////////
|
||||
void CallFuncsSpriteSheetForEach::update(float dt)
|
||||
{
|
||||
// iterate using fast enumeration protocol
|
||||
auto children = batchNode->getChildren();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
|
||||
std::for_each(std::begin(*children), std::end(*children), [](Object* obj) {
|
||||
static_cast<Node*>(obj)->getPosition();
|
||||
});
|
||||
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
}
|
||||
|
||||
|
||||
std::string CallFuncsSpriteSheetForEach::title()
|
||||
{
|
||||
return "D - 'map' functional call";
|
||||
}
|
||||
|
||||
std::string CallFuncsSpriteSheetForEach::subtitle()
|
||||
{
|
||||
return "Using 'std::for_each()'. See console";
|
||||
}
|
||||
|
||||
const char* CallFuncsSpriteSheetForEach::profilerName()
|
||||
{
|
||||
static char _name[256];
|
||||
snprintf(_name, sizeof(_name)-1, "Map: std::for_each(%d)", quantityOfNodes);
|
||||
return _name;
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// CallFuncsSpriteSheetCMacro
|
||||
//
|
||||
////////////////////////////////////////////////////////
|
||||
void CallFuncsSpriteSheetCMacro::update(float dt)
|
||||
{
|
||||
// iterate using fast enumeration protocol
|
||||
auto children = batchNode->getChildren();
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
|
||||
arrayMakeObjectsPerformSelector(children, getPosition, Node*);
|
||||
|
||||
CC_PROFILER_STOP(this->profilerName());
|
||||
}
|
||||
|
||||
|
||||
std::string CallFuncsSpriteSheetCMacro::title()
|
||||
{
|
||||
return "E - 'map' functional call";
|
||||
}
|
||||
|
||||
std::string CallFuncsSpriteSheetCMacro::subtitle()
|
||||
{
|
||||
return "Using 'arrayMakeObjectsPerformSelector'. See console";
|
||||
}
|
||||
|
||||
const char* CallFuncsSpriteSheetCMacro::profilerName()
|
||||
{
|
||||
static char _name[256];
|
||||
snprintf(_name, sizeof(_name)-1, "Map: arrayMakeObjectsPerformSelector(%d)", quantityOfNodes);
|
||||
return _name;
|
||||
}
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// AddRemoveSpriteSheet
|
||||
|
|
|
@ -94,6 +94,30 @@ protected:
|
|||
#endif
|
||||
};
|
||||
|
||||
///
|
||||
|
||||
class CallFuncsSpriteSheetForEach : public IterateSpriteSheet
|
||||
{
|
||||
public:
|
||||
virtual void update(float dt);
|
||||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual const char* profilerName();
|
||||
};
|
||||
|
||||
class CallFuncsSpriteSheetCMacro : public IterateSpriteSheet
|
||||
{
|
||||
public:
|
||||
virtual void update(float dt);
|
||||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual const char* profilerName();
|
||||
};
|
||||
|
||||
///
|
||||
|
||||
class AddSpriteSheet : public AddRemoveSpriteSheet
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue