mirror of https://github.com/axmolengine/axmol.git
Adds "Visit Scene Graph" tests
A new tests to measure the performance of visit Signed-off-by: Ricardo Quesada <ricardoquesada@gmail.com>
This commit is contained in:
parent
b057225fba
commit
7fb56bd123
|
@ -43,6 +43,8 @@ static std::function<NodeChildrenMainScene*()> createFunctions[] =
|
||||||
CL(RemoveSpriteSheet),
|
CL(RemoveSpriteSheet),
|
||||||
CL(ReorderSpriteSheet),
|
CL(ReorderSpriteSheet),
|
||||||
CL(SortAllChildrenSpriteSheet),
|
CL(SortAllChildrenSpriteSheet),
|
||||||
|
|
||||||
|
CL(VisitSceneGraph),
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
|
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
|
||||||
|
@ -814,6 +816,69 @@ const char* SortAllChildrenSpriteSheet::profilerName()
|
||||||
return "sort all children";
|
return "sort all children";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// VisitSceneGraph
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////
|
||||||
|
void VisitSceneGraph::initWithQuantityOfNodes(unsigned int nodes)
|
||||||
|
{
|
||||||
|
NodeChildrenMainScene::initWithQuantityOfNodes(nodes);
|
||||||
|
scheduleUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VisitSceneGraph::updateQuantityOfNodes()
|
||||||
|
{
|
||||||
|
auto s = Director::getInstance()->getWinSize();
|
||||||
|
|
||||||
|
// increase nodes
|
||||||
|
if( currentQuantityOfNodes < quantityOfNodes )
|
||||||
|
{
|
||||||
|
for(int i = 0; i < (quantityOfNodes-currentQuantityOfNodes); i++)
|
||||||
|
{
|
||||||
|
auto sprite = Sprite::create("Images/spritesheet1.png", Rect(0, 0, 32, 32));
|
||||||
|
this->addChild(sprite);
|
||||||
|
sprite->setVisible(true);
|
||||||
|
sprite->setPosition(Point(-1000,-1000));
|
||||||
|
sprite->setTag(1000 + currentQuantityOfNodes + i );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// decrease nodes
|
||||||
|
else if ( currentQuantityOfNodes > quantityOfNodes )
|
||||||
|
{
|
||||||
|
for(int i = 0; i < (currentQuantityOfNodes-quantityOfNodes); i++)
|
||||||
|
{
|
||||||
|
this->removeChildByTag(1000 + currentQuantityOfNodes - i -1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentQuantityOfNodes = quantityOfNodes;
|
||||||
|
}
|
||||||
|
void VisitSceneGraph::update(float dt)
|
||||||
|
{
|
||||||
|
CC_PROFILER_START( this->profilerName() );
|
||||||
|
this->visit();
|
||||||
|
CC_PROFILER_STOP( this->profilerName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string VisitSceneGraph::title()
|
||||||
|
{
|
||||||
|
return "K - Performance of visiting the scene graph";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string VisitSceneGraph::subtitle()
|
||||||
|
{
|
||||||
|
return "calls visit() on scene graph. See console";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* VisitSceneGraph::profilerName()
|
||||||
|
{
|
||||||
|
return "visit scene graph";
|
||||||
|
}
|
||||||
|
|
||||||
|
///----------------------------------------
|
||||||
void runNodeChildrenTest()
|
void runNodeChildrenTest()
|
||||||
{
|
{
|
||||||
auto scene = createFunctions[g_curCase]();
|
auto scene = createFunctions[g_curCase]();
|
||||||
|
|
|
@ -23,6 +23,7 @@ public:
|
||||||
virtual std::string title();
|
virtual std::string title();
|
||||||
virtual std::string subtitle();
|
virtual std::string subtitle();
|
||||||
virtual void updateQuantityOfNodes() = 0;
|
virtual void updateQuantityOfNodes() = 0;
|
||||||
|
virtual const char* profilerName() = 0;
|
||||||
|
|
||||||
void updateQuantityLabel();
|
void updateQuantityLabel();
|
||||||
|
|
||||||
|
@ -168,6 +169,18 @@ public:
|
||||||
virtual const char* profilerName();
|
virtual const char* profilerName();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VisitSceneGraph : public NodeChildrenMainScene
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void initWithQuantityOfNodes(unsigned int nodes) override;
|
||||||
|
|
||||||
|
virtual void update(float dt) override;
|
||||||
|
void updateQuantityOfNodes() override;
|
||||||
|
virtual std::string title() override;
|
||||||
|
virtual std::string subtitle() override;
|
||||||
|
virtual const char* profilerName() override;
|
||||||
|
};
|
||||||
|
|
||||||
void runNodeChildrenTest();
|
void runNodeChildrenTest();
|
||||||
|
|
||||||
#endif // __PERFORMANCE_NODE_CHILDREN_TEST_H__
|
#endif // __PERFORMANCE_NODE_CHILDREN_TEST_H__
|
||||||
|
|
Loading…
Reference in New Issue