mirror of https://github.com/axmolengine/axmol.git
Sprite Performance Test automation works OK
This commit is contained in:
parent
4e7a73243e
commit
96e089be76
|
@ -224,7 +224,7 @@ static void _log(const char *format, va_list args)
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
#else
|
#else
|
||||||
// Linux, Mac, iOS, etc
|
// Linux, Mac, iOS, etc
|
||||||
fprintf(stdout, "cocos2d: %s", buf);
|
fprintf(stdout, "%s", buf);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1086,13 +1086,14 @@ void Director::showStats()
|
||||||
|
|
||||||
float dt = _deltaTime * FPS_FILTER + (1-FPS_FILTER) * prevDeltaTime;
|
float dt = _deltaTime * FPS_FILTER + (1-FPS_FILTER) * prevDeltaTime;
|
||||||
prevDeltaTime = dt;
|
prevDeltaTime = dt;
|
||||||
|
_frameRate = 1/dt;
|
||||||
|
|
||||||
// Probably we don't need this anymore since
|
// Probably we don't need this anymore since
|
||||||
// the framerate is using a low-pass filter
|
// the framerate is using a low-pass filter
|
||||||
// to make the FPS stable
|
// to make the FPS stable
|
||||||
if (_accumDt > CC_DIRECTOR_STATS_INTERVAL)
|
if (_accumDt > CC_DIRECTOR_STATS_INTERVAL)
|
||||||
{
|
{
|
||||||
sprintf(buffer, "%.1f / %.3f", 1/dt, _secondsPerFrame);
|
sprintf(buffer, "%.1f / %.3f", _frameRate, _secondsPerFrame);
|
||||||
_FPSLabel->setString(buffer);
|
_FPSLabel->setString(buffer);
|
||||||
_accumDt = 0;
|
_accumDt = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ void SubTest::initWithSubTest(int subtest, Node* p)
|
||||||
{
|
{
|
||||||
srand(0);
|
srand(0);
|
||||||
|
|
||||||
subtestNumber = subtest;
|
_subtestNumber = subtest;
|
||||||
_parentNode = nullptr;
|
_parentNode = nullptr;
|
||||||
/*
|
/*
|
||||||
* Tests:
|
* Tests:
|
||||||
|
@ -73,6 +73,8 @@ void SubTest::initWithSubTest(int subtest, Node* p)
|
||||||
*10: 64 (32-bit) sprites of 32 x 32 each that belong to on texture atlas
|
*10: 64 (32-bit) sprites of 32 x 32 each that belong to on texture atlas
|
||||||
*11: 64 (32-bit) PNG Batch Node of 32 x 32 each
|
*11: 64 (32-bit) PNG Batch Node of 32 x 32 each
|
||||||
*12: 64 (16-bit) PNG Batch Node of 32 x 32 each
|
*12: 64 (16-bit) PNG Batch Node of 32 x 32 each
|
||||||
|
*
|
||||||
|
*13: (16-bit) PNG sprites. 33% from test4, 33% from test8, 33% from test12
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// purge textures
|
// purge textures
|
||||||
|
@ -81,7 +83,7 @@ void SubTest::initWithSubTest(int subtest, Node* p)
|
||||||
mgr->removeTextureForKey("Images/grossini_dance_atlas.png");
|
mgr->removeTextureForKey("Images/grossini_dance_atlas.png");
|
||||||
mgr->removeTextureForKey("Images/spritesheet1.png");
|
mgr->removeTextureForKey("Images/spritesheet1.png");
|
||||||
|
|
||||||
switch ( subtestNumber)
|
switch ( _subtestNumber)
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -147,7 +149,7 @@ Sprite* SubTest::createSpriteWithTag(int tag)
|
||||||
TextureCache *cache = Director::getInstance()->getTextureCache();
|
TextureCache *cache = Director::getInstance()->getTextureCache();
|
||||||
|
|
||||||
Sprite* sprite = nullptr;
|
Sprite* sprite = nullptr;
|
||||||
switch (subtestNumber)
|
switch (_subtestNumber)
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -327,25 +329,25 @@ void SpriteMenuLayer::showCurrentTest()
|
||||||
switch (_curCase)
|
switch (_curCase)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
scene = new (std::nothrow) SpritePerformTest1;
|
scene = new (std::nothrow) SpritePerformTestA;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
scene = new (std::nothrow) SpritePerformTest2;
|
scene = new (std::nothrow) SpritePerformTestB;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
scene = new (std::nothrow) SpritePerformTest3;
|
scene = new (std::nothrow) SpritePerformTestC;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
scene = new (std::nothrow) SpritePerformTest4;
|
scene = new (std::nothrow) SpritePerformTestD;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
scene = new (std::nothrow) SpritePerformTest5;
|
scene = new (std::nothrow) SpritePerformTestE;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
scene = new (std::nothrow) SpritePerformTest6;
|
scene = new (std::nothrow) SpritePerformTestF;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
scene = new (std::nothrow) SpritePerformTest7;
|
scene = new (std::nothrow) SpritePerformTestG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,21 +366,25 @@ void SpriteMenuLayer::showCurrentTest()
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// 500 sprites, 1500 sprites, etc...
|
||||||
bool SpriteMainScene::_s_autoTest = false;
|
bool SpriteMainScene::_s_autoTest = false;
|
||||||
int SpriteMainScene::_s_nSpriteCurCase = 0;
|
int SpriteMainScene::_s_nSpriteCurCase = 0;
|
||||||
|
int SpriteMainScene::_s_spritesQuatityIndex = 0;
|
||||||
|
int SpriteMainScene::_s_spritesQuanityArray[] = {500, 1000, 3000, 0};
|
||||||
|
std::vector<float> SpriteMainScene::_s_saved_fps = {};
|
||||||
|
|
||||||
void SpriteMainScene::initWithSubTest(int asubtest, int nNodes)
|
void SpriteMainScene::initWithSubTest(int asubtest, int nNodes)
|
||||||
{
|
{
|
||||||
//srandom(0);
|
//srandom(0);
|
||||||
|
|
||||||
subtestNumber = asubtest;
|
_subtestNumber = asubtest;
|
||||||
_subTest = new (std::nothrow) SubTest;
|
_subTest = new (std::nothrow) SubTest;
|
||||||
_subTest->initWithSubTest(asubtest, this);
|
_subTest->initWithSubTest(asubtest, this);
|
||||||
|
|
||||||
auto s = Director::getInstance()->getWinSize();
|
auto s = Director::getInstance()->getWinSize();
|
||||||
|
|
||||||
lastRenderedCount = 0;
|
_lastRenderedCount = 0;
|
||||||
quantityNodes = 0;
|
_quantityNodes = 0;
|
||||||
|
|
||||||
MenuItemFont::setFontSize(65);
|
MenuItemFont::setFontSize(65);
|
||||||
auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(SpriteMainScene::onDecrease, this));
|
auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(SpriteMainScene::onDecrease, this));
|
||||||
|
@ -464,7 +470,7 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes)
|
||||||
l->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 60) );
|
l->setPosition( Vec2(VisibleRect::center().x, VisibleRect::top().y - 60) );
|
||||||
}
|
}
|
||||||
|
|
||||||
while(quantityNodes < nNodes)
|
while(_quantityNodes < nNodes)
|
||||||
onIncrease(this);
|
onIncrease(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,34 +502,34 @@ void SpriteMainScene::testNCallback(Ref* sender)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
subtestNumber = static_cast<MenuItemFont*>(sender)->getTag();
|
_subtestNumber = static_cast<MenuItemFont*>(sender)->getTag();
|
||||||
auto menu = static_cast<SpriteMenuLayer*>( getChildByTag(kTagMenuLayer) );
|
auto menu = static_cast<SpriteMenuLayer*>( getChildByTag(kTagMenuLayer) );
|
||||||
menu->restartCallback(sender);
|
menu->restartCallback(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteMainScene::updateNodes()
|
void SpriteMainScene::updateNodes()
|
||||||
{
|
{
|
||||||
if( quantityNodes != lastRenderedCount )
|
if( _quantityNodes != _lastRenderedCount )
|
||||||
{
|
{
|
||||||
auto infoLabel = (Label *) getChildByTag(kTagInfoLayer);
|
auto infoLabel = (Label *) getChildByTag(kTagInfoLayer);
|
||||||
char str[16] = {0};
|
char str[16] = {0};
|
||||||
sprintf(str, "%u nodes", quantityNodes);
|
sprintf(str, "%u nodes", _quantityNodes);
|
||||||
infoLabel->setString(str);
|
infoLabel->setString(str);
|
||||||
|
|
||||||
lastRenderedCount = quantityNodes;
|
_lastRenderedCount = _quantityNodes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteMainScene::onIncrease(Ref* sender)
|
void SpriteMainScene::onIncrease(Ref* sender)
|
||||||
{
|
{
|
||||||
if( quantityNodes >= kMaxNodes)
|
if( _quantityNodes >= kMaxNodes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for( int i=0;i< kNodesIncrease;i++)
|
for( int i=0;i< kNodesIncrease;i++)
|
||||||
{
|
{
|
||||||
auto sprite = _subTest->createSpriteWithTag(quantityNodes);
|
auto sprite = _subTest->createSpriteWithTag(_quantityNodes);
|
||||||
doTest(sprite);
|
doTest(sprite);
|
||||||
quantityNodes++;
|
_quantityNodes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNodes();
|
updateNodes();
|
||||||
|
@ -532,13 +538,13 @@ void SpriteMainScene::onIncrease(Ref* sender)
|
||||||
void SpriteMainScene::onDecrease(Ref* sender)
|
void SpriteMainScene::onDecrease(Ref* sender)
|
||||||
{
|
{
|
||||||
|
|
||||||
if( quantityNodes <= 0 )
|
if( _quantityNodes <= 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for( int i=0;i < kNodesIncrease;i++)
|
for( int i=0;i < kNodesIncrease;i++)
|
||||||
{
|
{
|
||||||
quantityNodes--;
|
_quantityNodes--;
|
||||||
_subTest->removeByTag(quantityNodes);
|
_subTest->removeByTag(_quantityNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNodes();
|
updateNodes();
|
||||||
|
@ -546,42 +552,39 @@ void SpriteMainScene::onDecrease(Ref* sender)
|
||||||
|
|
||||||
void SpriteMainScene::dumpProfilerFPS()
|
void SpriteMainScene::dumpProfilerFPS()
|
||||||
{
|
{
|
||||||
if (_vecFPS.empty())
|
log("COPY & PASTE into Cocos2d-x Performance Test spreadsheet");
|
||||||
{
|
log("https://docs.google.com/spreadsheets/d/1XolpgYfoWszA2rxnVRCAVS7ILAGiV049o5mpL29cwLs/edit#gid=1561044615");
|
||||||
log("Error: the FPS vector is empty");
|
log("");
|
||||||
return;
|
int index = 0;
|
||||||
}
|
int sprites = 0;
|
||||||
|
while((sprites = _s_spritesQuanityArray[index++])) {
|
||||||
auto iter = _vecFPS.begin();
|
log("Number of sprites: %d", sprites);
|
||||||
float minFPS = *iter;
|
for(int i=0; i < MAX_SPRITE_TEST_CASE; i++)
|
||||||
float maxFPS = *iter;
|
{
|
||||||
float totalFPS = 0.0f;
|
char buffer[512];
|
||||||
float averagerFPS = 0.0f;
|
for(int j=0; j < MAX_SUB_TEST_NUMS; j++)
|
||||||
for (auto fps : _vecFPS)
|
{
|
||||||
{
|
float fps = _s_saved_fps[j + i*MAX_SUB_TEST_NUMS];
|
||||||
CCLOG("fps is :%f\n",fps);
|
char fps_str[64];
|
||||||
minFPS = std::min(minFPS, fps);
|
sprintf(fps_str, "\t%.1f", fps);
|
||||||
maxFPS = std::max(maxFPS, fps);
|
strcat(buffer, fps_str);
|
||||||
totalFPS += fps;
|
}
|
||||||
}
|
log("%c%s", i + 'A', buffer);
|
||||||
|
buffer[0] = 0;
|
||||||
averagerFPS = totalFPS / _vecFPS.size();
|
}
|
||||||
log("Cur test: %d, cur sub item :%d,cur sprite nums:%d, the min FPS value is %.1f,the max FPS value is %.1f,the averager FPS is %.1f", SpriteMainScene::_s_nSpriteCurCase, subtestNumber, quantityNodes, minFPS, maxFPS, averagerFPS);
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpriteMainScene::saveFPS()
|
||||||
|
{
|
||||||
|
float fps = Director::getInstance()->getFrameRate();
|
||||||
|
_s_saved_fps.push_back(fps);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteMainScene::updateAutoTest(float dt)
|
void SpriteMainScene::updateAutoTest(float dt)
|
||||||
{
|
{
|
||||||
if (SpriteMainScene::_s_autoTest)
|
saveFPS();
|
||||||
{
|
nextAutoTest();
|
||||||
_executeTimes += 1;
|
|
||||||
_vecFPS.push_back(Director::getInstance()->getFrameRate());
|
|
||||||
if ( _executeTimes >= SpriteMainScene::MAX_AUTO_TEST_TIMES )
|
|
||||||
{
|
|
||||||
dumpProfilerFPS();
|
|
||||||
nextAutoTest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteMainScene::onEnter()
|
void SpriteMainScene::onEnter()
|
||||||
|
@ -590,14 +593,11 @@ void SpriteMainScene::onEnter()
|
||||||
|
|
||||||
if ( SpriteMainScene::_s_autoTest )
|
if ( SpriteMainScene::_s_autoTest )
|
||||||
{
|
{
|
||||||
_vecFPS.clear();
|
|
||||||
_executeTimes = 0;
|
|
||||||
|
|
||||||
auto director = Director::getInstance();
|
auto director = Director::getInstance();
|
||||||
auto sched = director->getScheduler();
|
auto sched = director->getScheduler();
|
||||||
|
|
||||||
sched->schedule(CC_SCHEDULE_SELECTOR(SpriteMainScene::updateAutoTest), this, 0.2f, false);
|
// schedule it only once. Call me after 3 seconds
|
||||||
|
sched->schedule(CC_SCHEDULE_SELECTOR(SpriteMainScene::updateAutoTest), this, SECONDS_PER_TESTS, 0, 0, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -607,14 +607,13 @@ void SpriteMainScene::onExit()
|
||||||
{
|
{
|
||||||
auto director = Director::getInstance();
|
auto director = Director::getInstance();
|
||||||
auto sched = director->getScheduler();
|
auto sched = director->getScheduler();
|
||||||
|
|
||||||
sched->unschedule(CC_SCHEDULE_SELECTOR(SpriteMainScene::updateAutoTest), this );
|
sched->unschedule(CC_SCHEDULE_SELECTOR(SpriteMainScene::updateAutoTest), this );
|
||||||
}
|
}
|
||||||
|
|
||||||
Scene::onExit();
|
Scene::onExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteMainScene::autoShowSpriteTests(int curCase, int subTest,int nodes)
|
void SpriteMainScene::autoShowSpriteTests(int curCase, int subTest, int nodes)
|
||||||
{
|
{
|
||||||
|
|
||||||
SpriteMainScene* scene = nullptr;
|
SpriteMainScene* scene = nullptr;
|
||||||
|
@ -622,30 +621,31 @@ void SpriteMainScene::autoShowSpriteTests(int curCase, int subTest,int nodes)
|
||||||
switch (curCase)
|
switch (curCase)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
scene = new (std::nothrow) SpritePerformTest1;
|
scene = new (std::nothrow) SpritePerformTestA;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
scene = new (std::nothrow) SpritePerformTest2;
|
scene = new (std::nothrow) SpritePerformTestB;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
scene = new (std::nothrow) SpritePerformTest3;
|
scene = new (std::nothrow) SpritePerformTestC;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
scene = new (std::nothrow) SpritePerformTest4;
|
scene = new (std::nothrow) SpritePerformTestD;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
scene = new (std::nothrow) SpritePerformTest5;
|
scene = new (std::nothrow) SpritePerformTestE;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
scene = new (std::nothrow) SpritePerformTest6;
|
scene = new (std::nothrow) SpritePerformTestF;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
scene = new (std::nothrow) SpritePerformTest7;
|
scene = new (std::nothrow) SpritePerformTestG;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
CCASSERT(false, "Invalid scene value");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpriteMainScene::_s_nSpriteCurCase = curCase;
|
|
||||||
|
|
||||||
if (scene)
|
if (scene)
|
||||||
{
|
{
|
||||||
scene->initWithSubTest(subTest, nodes);
|
scene->initWithSubTest(subTest, nodes);
|
||||||
|
@ -656,15 +656,14 @@ void SpriteMainScene::autoShowSpriteTests(int curCase, int subTest,int nodes)
|
||||||
|
|
||||||
void SpriteMainScene::beginAutoTest()
|
void SpriteMainScene::beginAutoTest()
|
||||||
{
|
{
|
||||||
if (0 != SpriteMainScene::_s_nSpriteCurCase)
|
_s_spritesQuatityIndex = 0;
|
||||||
{
|
_s_nSpriteCurCase = 0;
|
||||||
SpriteMainScene::_s_nSpriteCurCase = 0;
|
_s_saved_fps.clear();
|
||||||
}
|
|
||||||
|
|
||||||
auto scene = new (std::nothrow) SpritePerformTest1;
|
_subtestNumber = 0;
|
||||||
scene->initWithSubTest(1, 500);
|
_quantityNodes = _s_spritesQuanityArray[_s_spritesQuatityIndex];
|
||||||
Director::getInstance()->replaceScene(scene);
|
|
||||||
scene->release();
|
nextAutoTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteMainScene::endAutoTest()
|
void SpriteMainScene::endAutoTest()
|
||||||
|
@ -679,25 +678,32 @@ void SpriteMainScene::endAutoTest()
|
||||||
|
|
||||||
void SpriteMainScene::nextAutoTest()
|
void SpriteMainScene::nextAutoTest()
|
||||||
{
|
{
|
||||||
if ( SpriteMainScene::_s_nSpriteCurCase < SpriteMainScene::MAX_SPRITE_TEST_CASE )
|
if (SpriteMainScene::_s_nSpriteCurCase < SpriteMainScene::MAX_SPRITE_TEST_CASE)
|
||||||
{
|
{
|
||||||
if ( subtestNumber < SpriteMainScene::MAX_SUB_TEST_NUMS )
|
if (_subtestNumber < SpriteMainScene::MAX_SUB_TEST_NUMS)
|
||||||
{
|
{
|
||||||
subtestNumber += 1;
|
// Increase Sub Main Test (1, 2, 3, 4, ...)
|
||||||
autoShowSpriteTests(SpriteMainScene::_s_nSpriteCurCase, subtestNumber, quantityNodes);
|
_subtestNumber += 1;
|
||||||
|
autoShowSpriteTests(_s_nSpriteCurCase, _subtestNumber, _quantityNodes);
|
||||||
}
|
}
|
||||||
else if ( subtestNumber == SpriteMainScene::MAX_SUB_TEST_NUMS )
|
else if (_subtestNumber == SpriteMainScene::MAX_SUB_TEST_NUMS)
|
||||||
{
|
{
|
||||||
if (quantityNodes == SpriteMainScene::AUTO_TEST_NODE_NUM1)
|
if (SpriteMainScene::_s_nSpriteCurCase + 1 < SpriteMainScene::MAX_SPRITE_TEST_CASE)
|
||||||
{
|
{
|
||||||
autoShowSpriteTests(SpriteMainScene::_s_nSpriteCurCase, 1, SpriteMainScene::AUTO_TEST_NODE_NUM2);
|
// Increase Main Test (A, B, C, ...)
|
||||||
|
_subtestNumber = 1;
|
||||||
|
_s_nSpriteCurCase++;
|
||||||
|
autoShowSpriteTests(_s_nSpriteCurCase, _subtestNumber, _quantityNodes);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SpriteMainScene::_s_nSpriteCurCase + 1 < SpriteMainScene::MAX_SPRITE_TEST_CASE)
|
// Increase quanity of sprites, or finish
|
||||||
{
|
int sprites = _s_spritesQuanityArray[++_s_spritesQuatityIndex];
|
||||||
SpriteMainScene::_s_nSpriteCurCase += 1;
|
if (sprites != 0) {
|
||||||
autoShowSpriteTests(SpriteMainScene::_s_nSpriteCurCase, 1, SpriteMainScene::AUTO_TEST_NODE_NUM1);
|
_quantityNodes = sprites;
|
||||||
|
_subtestNumber = 1;
|
||||||
|
_s_nSpriteCurCase = 0;
|
||||||
|
autoShowSpriteTests(_s_nSpriteCurCase, _subtestNumber, _quantityNodes);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -725,25 +731,25 @@ void SpriteMainScene::finishAutoTest()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log("Sprite performance test is finish ");
|
log("Sprite performance test is finished");
|
||||||
|
|
||||||
|
dumpProfilerFPS();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteMainScene::onAutoTest(Ref* sender)
|
void SpriteMainScene::onAutoTest(Ref* sender)
|
||||||
{
|
{
|
||||||
SpriteMainScene::_s_autoTest = !SpriteMainScene::_s_autoTest;
|
SpriteMainScene::_s_autoTest = !SpriteMainScene::_s_autoTest;
|
||||||
MenuItemFont* menuItem = dynamic_cast<MenuItemFont*>(sender);
|
MenuItemFont* menuItem = dynamic_cast<MenuItemFont*>(sender);
|
||||||
if (nullptr != menuItem)
|
|
||||||
|
if (SpriteMainScene::_s_autoTest)
|
||||||
{
|
{
|
||||||
if (SpriteMainScene::_s_autoTest)
|
menuItem->setString("Auto Test On");
|
||||||
{
|
beginAutoTest();
|
||||||
menuItem->setString("Auto Test On");
|
}
|
||||||
beginAutoTest();
|
else
|
||||||
}
|
{
|
||||||
else
|
menuItem->setString("Auto Test Off");
|
||||||
{
|
endAutoTest();
|
||||||
menuItem->setString("Auto Test Off");
|
|
||||||
endAutoTest();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -827,161 +833,126 @@ void performanceScale(Sprite* sprite)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SpritePerformTest1
|
// SpritePerformTestA
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
std::string SpritePerformTest1::title() const
|
std::string SpritePerformTestA::title() const
|
||||||
{
|
{
|
||||||
char str[32] = {0};
|
char str[32] = {0};
|
||||||
sprintf(str, "A (%d) position", subtestNumber);
|
sprintf(str, "A (%d) position", _subtestNumber);
|
||||||
std::string strRet = str;
|
std::string strRet = str;
|
||||||
return strRet;
|
return strRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SpritePerformTest1::subtitle() const
|
|
||||||
{
|
|
||||||
return "test 1";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void SpritePerformTestA::doTest(Sprite* sprite)
|
||||||
void SpritePerformTest1::doTest(Sprite* sprite)
|
|
||||||
{
|
{
|
||||||
performancePosition(sprite);
|
performancePosition(sprite);
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SpritePerformTest2
|
// SpritePerformTestB
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
std::string SpritePerformTest2::title() const
|
std::string SpritePerformTestB::title() const
|
||||||
{
|
{
|
||||||
char str[32] = {0};
|
char str[32] = {0};
|
||||||
sprintf(str, "B (%d) scale", subtestNumber);
|
sprintf(str, "B (%d) scale", _subtestNumber);
|
||||||
std::string strRet = str;
|
std::string strRet = str;
|
||||||
return strRet;
|
return strRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SpritePerformTest2::subtitle() const
|
void SpritePerformTestB::doTest(Sprite* sprite)
|
||||||
{
|
|
||||||
return "test 2";
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpritePerformTest2::doTest(Sprite* sprite)
|
|
||||||
{
|
{
|
||||||
performanceScale(sprite);
|
performanceScale(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SpritePerformTest3
|
// SpritePerformTestC
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
std::string SpritePerformTest3::title() const
|
std::string SpritePerformTestC::title() const
|
||||||
{
|
{
|
||||||
char str[32] = {0};
|
char str[32] = {0};
|
||||||
sprintf(str, "C (%d) scale + rot", subtestNumber);
|
sprintf(str, "C (%d) scale + rot", _subtestNumber);
|
||||||
std::string strRet = str;
|
std::string strRet = str;
|
||||||
return strRet;
|
return strRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SpritePerformTest3::subtitle() const
|
void SpritePerformTestC::doTest(Sprite* sprite)
|
||||||
{
|
|
||||||
return "test 3";
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpritePerformTest3::doTest(Sprite* sprite)
|
|
||||||
{
|
{
|
||||||
performanceRotationScale(sprite);
|
performanceRotationScale(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SpritePerformTest4
|
// SpritePerformTestD
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
std::string SpritePerformTest4::title() const
|
std::string SpritePerformTestD::title() const
|
||||||
{
|
{
|
||||||
char str[32] = {0};
|
char str[32] = {0};
|
||||||
sprintf(str, "D (%d) 100%% out", subtestNumber);
|
sprintf(str, "D (%d) 100%% out", _subtestNumber);
|
||||||
std::string strRet = str;
|
std::string strRet = str;
|
||||||
return strRet;
|
return strRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SpritePerformTest4::subtitle() const
|
void SpritePerformTestD::doTest(Sprite* sprite)
|
||||||
{
|
|
||||||
return "test 4";
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpritePerformTest4::doTest(Sprite* sprite)
|
|
||||||
{
|
{
|
||||||
performanceOut100(sprite);
|
performanceOut100(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SpritePerformTest5
|
// SpritePerformTestE
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
std::string SpritePerformTest5::title() const
|
std::string SpritePerformTestE::title() const
|
||||||
{
|
{
|
||||||
char str[32] = {0};
|
char str[32] = {0};
|
||||||
sprintf(str, "E (%d) 80%% out", subtestNumber);
|
sprintf(str, "E (%d) 80%% out", _subtestNumber);
|
||||||
std::string strRet = str;
|
std::string strRet = str;
|
||||||
return strRet;
|
return strRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SpritePerformTest5::subtitle() const
|
void SpritePerformTestE::doTest(Sprite* sprite)
|
||||||
{
|
|
||||||
return "test 5";
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpritePerformTest5::doTest(Sprite* sprite)
|
|
||||||
{
|
{
|
||||||
performanceout20(sprite);
|
performanceout20(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SpritePerformTest6
|
// SpritePerformTestF
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
std::string SpritePerformTest6::title() const
|
std::string SpritePerformTestF::title() const
|
||||||
{
|
{
|
||||||
char str[32] = {0};
|
char str[32] = {0};
|
||||||
sprintf(str, "F (%d) actions", subtestNumber);
|
sprintf(str, "F (%d) actions", _subtestNumber);
|
||||||
std::string strRet = str;
|
std::string strRet = str;
|
||||||
return strRet;
|
return strRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SpritePerformTest6::subtitle() const
|
void SpritePerformTestF::doTest(Sprite* sprite)
|
||||||
{
|
|
||||||
return "test 6";
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpritePerformTest6::doTest(Sprite* sprite)
|
|
||||||
{
|
{
|
||||||
performanceActions(sprite);
|
performanceActions(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SpritePerformTest7
|
// SpritePerformTestG
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
std::string SpritePerformTest7::title() const
|
std::string SpritePerformTestG::title() const
|
||||||
{
|
{
|
||||||
char str[32] = {0};
|
char str[32] = {0};
|
||||||
sprintf(str, "G (%d) actions 80%% out", subtestNumber);
|
sprintf(str, "G (%d) actions 80%% out", _subtestNumber);
|
||||||
std::string strRet = str;
|
std::string strRet = str;
|
||||||
return strRet;
|
return strRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SpritePerformTest7::subtitle() const
|
void SpritePerformTestG::doTest(Sprite* sprite)
|
||||||
{
|
|
||||||
return "test 7";
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpritePerformTest7::doTest(Sprite* sprite)
|
|
||||||
{
|
{
|
||||||
performanceActions20(sprite);
|
performanceActions20(sprite);
|
||||||
}
|
}
|
||||||
|
@ -989,7 +960,7 @@ void SpritePerformTest7::doTest(Sprite* sprite)
|
||||||
void runSpriteTest()
|
void runSpriteTest()
|
||||||
{
|
{
|
||||||
SpriteMainScene::_s_autoTest = false;
|
SpriteMainScene::_s_autoTest = false;
|
||||||
auto scene = new (std::nothrow) SpritePerformTest1;
|
auto scene = new (std::nothrow) SpritePerformTestA;
|
||||||
scene->initWithSubTest(1, 50);
|
scene->initWithSubTest(1, 50);
|
||||||
Director::getInstance()->replaceScene(scene);
|
Director::getInstance()->replaceScene(scene);
|
||||||
scene->release();
|
scene->release();
|
||||||
|
|
|
@ -28,8 +28,11 @@
|
||||||
#ifndef __PERFORMANCE_SPRITE_TEST_H__
|
#ifndef __PERFORMANCE_SPRITE_TEST_H__
|
||||||
#define __PERFORMANCE_SPRITE_TEST_H__
|
#define __PERFORMANCE_SPRITE_TEST_H__
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "PerformanceTest.h"
|
#include "PerformanceTest.h"
|
||||||
|
|
||||||
|
|
||||||
class SubTest
|
class SubTest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -39,7 +42,7 @@ public:
|
||||||
void initWithSubTest(int nSubTest, Node* parent);
|
void initWithSubTest(int nSubTest, Node* parent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int subtestNumber;
|
int _subtestNumber;
|
||||||
Node *_parentNode;
|
Node *_parentNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,93 +76,87 @@ public:
|
||||||
|
|
||||||
virtual void doTest(Sprite* sprite) = 0;
|
virtual void doTest(Sprite* sprite) = 0;
|
||||||
|
|
||||||
int getSubTestNum() { return subtestNumber; }
|
int getSubTestNum() { return _subtestNumber; }
|
||||||
int getNodesNum() { return quantityNodes; }
|
int getNodesNum() { return _quantityNodes; }
|
||||||
|
|
||||||
virtual void onEnter() override;
|
virtual void onEnter() override;
|
||||||
virtual void onExit() override;
|
virtual void onExit() override;
|
||||||
void updateAutoTest(float dt);
|
void updateAutoTest(float dt);
|
||||||
void onAutoTest(Ref* sender);
|
void onAutoTest(Ref* sender);
|
||||||
|
|
||||||
|
// auto tests
|
||||||
static bool _s_autoTest;
|
static bool _s_autoTest;
|
||||||
static int _s_nSpriteCurCase;
|
static int _s_nSpriteCurCase;
|
||||||
|
static int _s_spritesQuatityIndex;
|
||||||
|
static int _s_spritesQuanityArray[];
|
||||||
|
static std::vector<float> _s_saved_fps;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void dumpProfilerFPS();
|
void dumpProfilerFPS();
|
||||||
void beginAutoTest();
|
void saveFPS();
|
||||||
void endAutoTest();
|
void beginAutoTest();
|
||||||
void nextAutoTest();
|
void endAutoTest();
|
||||||
void finishAutoTest();
|
void nextAutoTest();
|
||||||
void autoShowSpriteTests(int curCase, int subTest,int nodes);
|
void finishAutoTest();
|
||||||
|
void autoShowSpriteTests(int curCase, int subTest,int nodes);
|
||||||
|
|
||||||
int lastRenderedCount;
|
int _lastRenderedCount;
|
||||||
int quantityNodes;
|
int _quantityNodes;
|
||||||
SubTest *_subTest;
|
SubTest* _subTest;
|
||||||
int subtestNumber;
|
int _subtestNumber;
|
||||||
std::vector<float> _vecFPS;
|
|
||||||
int _executeTimes;
|
|
||||||
|
|
||||||
static const int MAX_AUTO_TEST_TIMES = 25;
|
constexpr static const float SECONDS_PER_TESTS = 3.0f;
|
||||||
static const int MAX_SPRITE_TEST_CASE = 7;
|
static const int MAX_SPRITE_TEST_CASE = 7;
|
||||||
static const int MAX_SUB_TEST_NUMS = 13;
|
static const int MAX_SUB_TEST_NUMS = 13;
|
||||||
static const int AUTO_TEST_NODE_NUM1 = 500;
|
|
||||||
static const int AUTO_TEST_NODE_NUM2 = 1500;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpritePerformTest1 : public SpriteMainScene
|
class SpritePerformTestA : public SpriteMainScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void doTest(Sprite* sprite) override;
|
virtual void doTest(Sprite* sprite) override;
|
||||||
virtual std::string title() const override;
|
virtual std::string title() const override;
|
||||||
virtual std::string subtitle() const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpritePerformTest2 : public SpriteMainScene
|
class SpritePerformTestB : public SpriteMainScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void doTest(Sprite* sprite) override;
|
virtual void doTest(Sprite* sprite) override;
|
||||||
virtual std::string title() const override;
|
virtual std::string title() const override;
|
||||||
virtual std::string subtitle() const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpritePerformTest3 : public SpriteMainScene
|
class SpritePerformTestC : public SpriteMainScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void doTest(Sprite* sprite) override;
|
virtual void doTest(Sprite* sprite) override;
|
||||||
virtual std::string title() const override;
|
virtual std::string title() const override;
|
||||||
virtual std::string subtitle() const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpritePerformTest4 : public SpriteMainScene
|
class SpritePerformTestD : public SpriteMainScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void doTest(Sprite* sprite) override;
|
virtual void doTest(Sprite* sprite) override;
|
||||||
virtual std::string title() const override;
|
virtual std::string title() const override;
|
||||||
virtual std::string subtitle() const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpritePerformTest5 : public SpriteMainScene
|
class SpritePerformTestE : public SpriteMainScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void doTest(Sprite* sprite) override;
|
virtual void doTest(Sprite* sprite) override;
|
||||||
virtual std::string title() const override;
|
virtual std::string title() const override;
|
||||||
virtual std::string subtitle() const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpritePerformTest6 : public SpriteMainScene
|
class SpritePerformTestF : public SpriteMainScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void doTest(Sprite* sprite) override;
|
virtual void doTest(Sprite* sprite) override;
|
||||||
virtual std::string title() const override;
|
virtual std::string title() const override;
|
||||||
virtual std::string subtitle() const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpritePerformTest7 : public SpriteMainScene
|
class SpritePerformTestG : public SpriteMainScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void doTest(Sprite* sprite) override;
|
virtual void doTest(Sprite* sprite) override;
|
||||||
virtual std::string title() const override;
|
virtual std::string title() const override;
|
||||||
virtual std::string subtitle() const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void runSpriteTest();
|
void runSpriteTest();
|
||||||
|
|
Loading…
Reference in New Issue