mirror of https://github.com/axmolengine/axmol.git
More accurate test
Name is recalculated. No time is "wasted" in calculating it. And `Visit` test uses `Node` objects instead of `Sprite`s. So `draw` is not taken into account, just the visit. Signed-off-by: Ricardo Quesada <ricardoquesada@gmail.com>
This commit is contained in:
parent
530a0119ae
commit
c04409b6d5
|
@ -149,7 +149,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
|
|||
|
||||
updateQuantityLabel();
|
||||
updateQuantityOfNodes();
|
||||
|
||||
updateProfilerName();
|
||||
CC_PROFILER_PURGE_ALL();
|
||||
});
|
||||
decrease->setColor(Color3B(0,200,20));
|
||||
|
@ -160,7 +160,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
|
|||
|
||||
updateQuantityLabel();
|
||||
updateQuantityOfNodes();
|
||||
|
||||
updateProfilerName();
|
||||
CC_PROFILER_PURGE_ALL();
|
||||
});
|
||||
increase->setColor(Color3B(0,200,20));
|
||||
|
@ -181,6 +181,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
|
|||
|
||||
updateQuantityLabel();
|
||||
updateQuantityOfNodes();
|
||||
updateProfilerName();
|
||||
}
|
||||
|
||||
std::string NodeChildrenMainScene::title()
|
||||
|
@ -206,6 +207,17 @@ void NodeChildrenMainScene::updateQuantityLabel()
|
|||
}
|
||||
}
|
||||
|
||||
const char * NodeChildrenMainScene::profilerName()
|
||||
{
|
||||
return _profilerName;
|
||||
}
|
||||
|
||||
void NodeChildrenMainScene::updateProfilerName()
|
||||
{
|
||||
snprintf(_profilerName, sizeof(_profilerName)-1, "%s(%d)", testName(), quantityOfNodes);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// IterateSpriteSheet
|
||||
|
@ -255,7 +267,7 @@ void IterateSpriteSheet::initWithQuantityOfNodes(unsigned int nNodes)
|
|||
scheduleUpdate();
|
||||
}
|
||||
|
||||
const char* IterateSpriteSheet::profilerName()
|
||||
const char* IterateSpriteSheet::testName()
|
||||
{
|
||||
return "none";
|
||||
}
|
||||
|
@ -292,7 +304,7 @@ std::string IterateSpriteSheetForLoop::subtitle()
|
|||
return "Iterate children using C++11 range-based for loop. See console";
|
||||
}
|
||||
|
||||
const char* IterateSpriteSheetForLoop::profilerName()
|
||||
const char* IterateSpriteSheetForLoop::testName()
|
||||
{
|
||||
return "Iterator: C++11 for loop";
|
||||
}
|
||||
|
@ -330,7 +342,7 @@ std::string IterateSpriteSheetCArray::subtitle()
|
|||
return "Iterate children using C Array API. See console";
|
||||
}
|
||||
|
||||
const char* IterateSpriteSheetCArray::profilerName()
|
||||
const char* IterateSpriteSheetCArray::testName()
|
||||
{
|
||||
return "Iterator: CC_ARRAY_FOREACH";
|
||||
}
|
||||
|
@ -368,7 +380,7 @@ std::string IterateSpriteSheetIterator::subtitle()
|
|||
return "Iterate children using begin() / end(). See console";
|
||||
}
|
||||
|
||||
const char* IterateSpriteSheetIterator::profilerName()
|
||||
const char* IterateSpriteSheetIterator::testName()
|
||||
{
|
||||
return "Iterator: begin(), end()";
|
||||
}
|
||||
|
@ -409,12 +421,9 @@ std::string CallFuncsSpriteSheetForEach::subtitle()
|
|||
return "Using 'std::for_each()'. See console";
|
||||
}
|
||||
|
||||
const char* CallFuncsSpriteSheetForEach::profilerName()
|
||||
const char* CallFuncsSpriteSheetForEach::testName()
|
||||
{
|
||||
static char _name[256];
|
||||
snprintf(_name, sizeof(_name)-1, "Map: std::for_each(%d)", quantityOfNodes);
|
||||
return _name;
|
||||
|
||||
return "Map: std::for_each";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
|
@ -445,11 +454,9 @@ std::string CallFuncsSpriteSheetCMacro::subtitle()
|
|||
return "Using 'arrayMakeObjectsPerformSelector'. See console";
|
||||
}
|
||||
|
||||
const char* CallFuncsSpriteSheetCMacro::profilerName()
|
||||
const char* CallFuncsSpriteSheetCMacro::testName()
|
||||
{
|
||||
static char _name[256];
|
||||
snprintf(_name, sizeof(_name)-1, "Map: arrayMakeObjectsPerformSelector(%d)", quantityOfNodes);
|
||||
return _name;
|
||||
return "Map: arrayMakeObjectsPerformSelector";
|
||||
}
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -499,7 +506,7 @@ void AddRemoveSpriteSheet::updateQuantityOfNodes()
|
|||
currentQuantityOfNodes = quantityOfNodes;
|
||||
}
|
||||
|
||||
const char* AddRemoveSpriteSheet::profilerName()
|
||||
const char* AddRemoveSpriteSheet::testName()
|
||||
{
|
||||
return "none";
|
||||
}
|
||||
|
@ -562,7 +569,7 @@ std::string AddSpriteSheet::subtitle()
|
|||
return "Adds %10 of total sprites with random z. See console";
|
||||
}
|
||||
|
||||
const char* AddSpriteSheet::profilerName()
|
||||
const char* AddSpriteSheet::testName()
|
||||
{
|
||||
return "add sprites";
|
||||
}
|
||||
|
@ -627,7 +634,7 @@ std::string GetSpriteSheet::subtitle()
|
|||
return "Get sprites using getChildByTag(). See console";
|
||||
}
|
||||
|
||||
const char* GetSpriteSheet::profilerName()
|
||||
const char* GetSpriteSheet::testName()
|
||||
{
|
||||
return "get sprites";
|
||||
}
|
||||
|
@ -683,7 +690,7 @@ std::string RemoveSpriteSheet::subtitle()
|
|||
return "Remove %10 of total sprites placed randomly. See console";
|
||||
}
|
||||
|
||||
const char* RemoveSpriteSheet::profilerName()
|
||||
const char* RemoveSpriteSheet::testName()
|
||||
{
|
||||
return "remove sprites";
|
||||
}
|
||||
|
@ -746,7 +753,7 @@ std::string ReorderSpriteSheet::subtitle()
|
|||
return "Reorder %10 of total sprites placed randomly. See console";
|
||||
}
|
||||
|
||||
const char* ReorderSpriteSheet::profilerName()
|
||||
const char* ReorderSpriteSheet::testName()
|
||||
{
|
||||
return "reorder sprites";
|
||||
}
|
||||
|
@ -811,7 +818,7 @@ std::string SortAllChildrenSpriteSheet::subtitle()
|
|||
return "Calls sortOfChildren(). See console";
|
||||
}
|
||||
|
||||
const char* SortAllChildrenSpriteSheet::profilerName()
|
||||
const char* SortAllChildrenSpriteSheet::testName()
|
||||
{
|
||||
return "sort all children";
|
||||
}
|
||||
|
@ -837,11 +844,11 @@ void VisitSceneGraph::updateQuantityOfNodes()
|
|||
{
|
||||
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 );
|
||||
auto node = Node::create();
|
||||
this->addChild(node);
|
||||
node->setVisible(true);
|
||||
node->setPosition(Point(-1000,-1000));
|
||||
node->setTag(1000 + currentQuantityOfNodes + i );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -873,7 +880,7 @@ std::string VisitSceneGraph::subtitle()
|
|||
return "calls visit() on scene graph. See console";
|
||||
}
|
||||
|
||||
const char* VisitSceneGraph::profilerName()
|
||||
const char* VisitSceneGraph::testName()
|
||||
{
|
||||
return "visit scene graph";
|
||||
}
|
||||
|
|
|
@ -23,13 +23,19 @@ public:
|
|||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual void updateQuantityOfNodes() = 0;
|
||||
virtual const char* profilerName() = 0;
|
||||
|
||||
const char* profilerName();
|
||||
void updateProfilerName();
|
||||
|
||||
// for the profiler
|
||||
virtual const char* testName() = 0;
|
||||
|
||||
void updateQuantityLabel();
|
||||
|
||||
int getQuantityOfNodes() { return quantityOfNodes; }
|
||||
|
||||
protected:
|
||||
char _profilerName[256];
|
||||
int lastRenderedCount;
|
||||
int quantityOfNodes;
|
||||
int currentQuantityOfNodes;
|
||||
|
@ -42,7 +48,7 @@ public:
|
|||
virtual void updateQuantityOfNodes();
|
||||
virtual void initWithQuantityOfNodes(unsigned int nNodes);
|
||||
virtual void update(float dt) = 0;
|
||||
virtual const char* profilerName();
|
||||
virtual const char* testName();
|
||||
|
||||
protected:
|
||||
SpriteBatchNode *batchNode;
|
||||
|
@ -55,7 +61,7 @@ public:
|
|||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual const char* profilerName();
|
||||
virtual const char* testName();
|
||||
};
|
||||
|
||||
class IterateSpriteSheetIterator : public IterateSpriteSheet
|
||||
|
@ -65,7 +71,7 @@ public:
|
|||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual const char* profilerName();
|
||||
virtual const char* testName();
|
||||
};
|
||||
|
||||
class IterateSpriteSheetCArray : public IterateSpriteSheet
|
||||
|
@ -75,7 +81,7 @@ public:
|
|||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual const char* profilerName();
|
||||
virtual const char* testName();
|
||||
};
|
||||
|
||||
class AddRemoveSpriteSheet : public NodeChildrenMainScene
|
||||
|
@ -85,7 +91,7 @@ public:
|
|||
virtual void updateQuantityOfNodes();
|
||||
virtual void initWithQuantityOfNodes(unsigned int nNodes);
|
||||
virtual void update(float dt) = 0;
|
||||
virtual const char* profilerName();
|
||||
virtual const char* testName();
|
||||
|
||||
protected:
|
||||
SpriteBatchNode *batchNode;
|
||||
|
@ -104,7 +110,7 @@ public:
|
|||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual const char* profilerName();
|
||||
virtual const char* testName();
|
||||
};
|
||||
|
||||
class CallFuncsSpriteSheetCMacro : public IterateSpriteSheet
|
||||
|
@ -114,7 +120,7 @@ public:
|
|||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual const char* profilerName();
|
||||
virtual const char* testName();
|
||||
};
|
||||
|
||||
///
|
||||
|
@ -126,7 +132,7 @@ public:
|
|||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual const char* profilerName();
|
||||
virtual const char* testName();
|
||||
};
|
||||
|
||||
class GetSpriteSheet : public AddRemoveSpriteSheet
|
||||
|
@ -136,7 +142,7 @@ public:
|
|||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual const char* profilerName();
|
||||
virtual const char* testName();
|
||||
};
|
||||
|
||||
class RemoveSpriteSheet : public AddRemoveSpriteSheet
|
||||
|
@ -146,7 +152,7 @@ public:
|
|||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual const char* profilerName();
|
||||
virtual const char* testName();
|
||||
};
|
||||
|
||||
class ReorderSpriteSheet : public AddRemoveSpriteSheet
|
||||
|
@ -156,7 +162,7 @@ public:
|
|||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual const char* profilerName();
|
||||
virtual const char* testName();
|
||||
};
|
||||
|
||||
class SortAllChildrenSpriteSheet : public AddRemoveSpriteSheet
|
||||
|
@ -166,7 +172,7 @@ public:
|
|||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
virtual const char* profilerName();
|
||||
virtual const char* testName();
|
||||
};
|
||||
|
||||
class VisitSceneGraph : public NodeChildrenMainScene
|
||||
|
@ -178,7 +184,7 @@ public:
|
|||
void updateQuantityOfNodes() override;
|
||||
virtual std::string title() override;
|
||||
virtual std::string subtitle() override;
|
||||
virtual const char* profilerName() override;
|
||||
virtual const char* testName() override;
|
||||
};
|
||||
|
||||
void runNodeChildrenTest();
|
||||
|
|
Loading…
Reference in New Issue