From 02500372ed760afbc1d2df75ee2646b2b7b3e719 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 5 Sep 2013 20:02:04 -0700 Subject: [PATCH 1/4] Adds new perf test: alloc / dealloc --- .../PerformanceTest/PerformanceAllocTest.cpp | 430 ++++++++++++++++++ .../PerformanceTest/PerformanceAllocTest.h | 100 ++++ .../PerformanceTest/PerformanceTest.cpp | 12 +- .../project.pbxproj.REMOVED.git-id | 2 +- 4 files changed, 538 insertions(+), 6 deletions(-) create mode 100644 samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp create mode 100644 samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.h diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp new file mode 100644 index 0000000000..09fbd94d7e --- /dev/null +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp @@ -0,0 +1,430 @@ +/* + * + */ +#include "PerformanceAllocTest.h" + +#include + +// Enable profiles for this file +#undef CC_PROFILER_DISPLAY_TIMERS +#define CC_PROFILER_DISPLAY_TIMERS() Profiler::getInstance()->displayTimers() +#undef CC_PROFILER_PURGE_ALL +#define CC_PROFILER_PURGE_ALL() Profiler::getInstance()->releaseAllTimers() + +#undef CC_PROFILER_START +#define CC_PROFILER_START(__name__) ProfilingBeginTimingBlock(__name__) +#undef CC_PROFILER_STOP +#define CC_PROFILER_STOP(__name__) ProfilingEndTimingBlock(__name__) +#undef CC_PROFILER_RESET +#define CC_PROFILER_RESET(__name__) ProfilingResetTimingBlock(__name__) + +#undef CC_PROFILER_START_CATEGORY +#define CC_PROFILER_START_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingBeginTimingBlock(__name__); } while(0) +#undef CC_PROFILER_STOP_CATEGORY +#define CC_PROFILER_STOP_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingEndTimingBlock(__name__); } while(0) +#undef CC_PROFILER_RESET_CATEGORY +#define CC_PROFILER_RESET_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingResetTimingBlock(__name__); } while(0) + +#undef CC_PROFILER_START_INSTANCE +#define CC_PROFILER_START_INSTANCE(__id__, __name__) do{ ProfilingBeginTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) +#undef CC_PROFILER_STOP_INSTANCE +#define CC_PROFILER_STOP_INSTANCE(__id__, __name__) do{ ProfilingEndTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) +#undef CC_PROFILER_RESET_INSTANCE +#define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ ProfilingResetTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) + +static std::function createFunctions[] = +{ + CL(NodeCreateTest), + CL(NodeDeallocTest), + CL(SpriteCreateTest), + CL(SpriteDeallocTest), +}; + +#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) + +enum { + kTagInfoLayer = 1, + + kTagBase = 20000, +}; + +enum { + kMaxNodes = 15000, + kNodesIncrease = 500, +}; + +static int g_curCase = 0; + +//////////////////////////////////////////////////////// +// +// AllocBasicLayer +// +//////////////////////////////////////////////////////// + +AllocBasicLayer::AllocBasicLayer(bool bControlMenuVisible, int nMaxCases, int nCurCase) +: PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) +{ +} + +void AllocBasicLayer::showCurrentTest() +{ + int nodes = ((PerformceAllocScene*)getParent())->getQuantityOfNodes(); + + auto scene = createFunctions[_curCase](); + + g_curCase = _curCase; + + if (scene) + { + scene->initWithQuantityOfNodes(nodes); + + Director::getInstance()->replaceScene(scene); + scene->release(); + } +} + +//////////////////////////////////////////////////////// +// +// PerformceAllocScene +// +//////////////////////////////////////////////////////// +void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes) +{ + //srand(time()); + auto s = Director::getInstance()->getWinSize(); + + // Title + auto label = LabelTTF::create(title().c_str(), "Arial", 40); + addChild(label, 1); + label->setPosition(Point(s.width/2, s.height-32)); + label->setColor(Color3B(255,255,40)); + + // Subtitle + std::string strSubTitle = subtitle(); + if(strSubTitle.length()) + { + auto l = LabelTTF::create(strSubTitle.c_str(), "Thonburi", 16); + addChild(l, 1); + l->setPosition(Point(s.width/2, s.height-80)); + } + + lastRenderedCount = 0; + currentQuantityOfNodes = 0; + quantityOfNodes = nNodes; + + MenuItemFont::setFontSize(65); + auto decrease = MenuItemFont::create(" - ", [&](Object *sender) { + quantityOfNodes -= kNodesIncrease; + if( quantityOfNodes < 0 ) + quantityOfNodes = 0; + + updateQuantityLabel(); + updateQuantityOfNodes(); + updateProfilerName(); + CC_PROFILER_PURGE_ALL(); + srandom(0); + }); + decrease->setColor(Color3B(0,200,20)); + auto increase = MenuItemFont::create(" + ", [&](Object *sender) { + quantityOfNodes += kNodesIncrease; + if( quantityOfNodes > kMaxNodes ) + quantityOfNodes = kMaxNodes; + + updateQuantityLabel(); + updateQuantityOfNodes(); + updateProfilerName(); + CC_PROFILER_PURGE_ALL(); + srandom(0); + }); + increase->setColor(Color3B(0,200,20)); + + auto menu = Menu::create(decrease, increase, NULL); + menu->alignItemsHorizontally(); + menu->setPosition(Point(s.width/2, s.height/2+15)); + addChild(menu, 1); + + auto infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30); + infoLabel->setColor(Color3B(0,200,20)); + infoLabel->setPosition(Point(s.width/2, s.height/2-15)); + addChild(infoLabel, 1, kTagInfoLayer); + + auto menuLayer = new AllocBasicLayer(true, MAX_LAYER, g_curCase); + addChild(menuLayer); + menuLayer->release(); + + updateQuantityLabel(); + updateQuantityOfNodes(); + updateProfilerName(); + srandom(0); +} + +std::string PerformceAllocScene::title() +{ + return "No title"; +} + +std::string PerformceAllocScene::subtitle() +{ + return ""; +} + +void PerformceAllocScene::updateQuantityLabel() +{ + if( quantityOfNodes != lastRenderedCount ) + { + auto infoLabel = static_cast( getChildByTag(kTagInfoLayer) ); + char str[20] = {0}; + sprintf(str, "%u nodes", quantityOfNodes); + infoLabel->setString(str); + + lastRenderedCount = quantityOfNodes; + } +} + +const char * PerformceAllocScene::profilerName() +{ + return _profilerName; +} + +void PerformceAllocScene::updateProfilerName() +{ + snprintf(_profilerName, sizeof(_profilerName)-1, "%s(%d)", testName(), quantityOfNodes); +} + +void PerformceAllocScene::onExitTransitionDidStart() +{ + Scene::onExitTransitionDidStart(); + + auto director = Director::getInstance(); + auto sched = director->getScheduler(); + + sched->unscheduleSelector(SEL_SCHEDULE(&PerformceAllocScene::dumpProfilerInfo), this); +} + +void PerformceAllocScene::onEnterTransitionDidFinish() +{ + Scene::onEnterTransitionDidFinish(); + + auto director = Director::getInstance(); + auto sched = director->getScheduler(); + + CC_PROFILER_PURGE_ALL(); + sched->scheduleSelector(SEL_SCHEDULE(&PerformceAllocScene::dumpProfilerInfo), this, 2, false); +} + +void PerformceAllocScene::dumpProfilerInfo(float dt) +{ + CC_PROFILER_DISPLAY_TIMERS(); +} + +//////////////////////////////////////////////////////// +// +// NodeCreateTest +// +//////////////////////////////////////////////////////// +void NodeCreateTest::updateQuantityOfNodes() +{ + currentQuantityOfNodes = quantityOfNodes; +} + +void NodeCreateTest::initWithQuantityOfNodes(unsigned int nNodes) +{ + PerformceAllocScene::initWithQuantityOfNodes(nNodes); + + printf("Size of Node: %lu\n", sizeof(Node)); + + scheduleUpdate(); +} + +void NodeCreateTest::update(float dt) +{ + // iterate using fast enumeration protocol + + Node **nodes = new Node*[quantityOfNodes]; + + CC_PROFILER_START(this->profilerName()); + for( int i=0; iprofilerName()); + + delete [] nodes; +} + +std::string NodeCreateTest::title() +{ + return "Node Create Perf test."; +} + +std::string NodeCreateTest::subtitle() +{ + return "Node Create Perf test. See console"; +} + +const char* NodeCreateTest::testName() +{ + return "Node::create()"; +} + +//////////////////////////////////////////////////////// +// +// NodeDeallocTest +// +//////////////////////////////////////////////////////// +void NodeDeallocTest::updateQuantityOfNodes() +{ + currentQuantityOfNodes = quantityOfNodes; +} + +void NodeDeallocTest::initWithQuantityOfNodes(unsigned int nNodes) +{ + PerformceAllocScene::initWithQuantityOfNodes(nNodes); + + printf("Size of Sprite: %lu\n", sizeof(Node)); + + scheduleUpdate(); +} + +void NodeDeallocTest::update(float dt) +{ + // iterate using fast enumeration protocol + + Node **nodes = new Node*[quantityOfNodes]; + + for( int i=0; iinit(); + } + + CC_PROFILER_START(this->profilerName()); + for( int i=0; irelease(); + CC_PROFILER_STOP(this->profilerName()); + + delete [] nodes; +} + +std::string NodeDeallocTest::title() +{ + return "Node Dealloc Perf test."; +} + +std::string NodeDeallocTest::subtitle() +{ + return "Node Dealloc Perf test. See console"; +} + +const char* NodeDeallocTest::testName() +{ + return "Node::~Node()"; +} + +//////////////////////////////////////////////////////// +// +// SpriteCreateTest +// +//////////////////////////////////////////////////////// +void SpriteCreateTest::updateQuantityOfNodes() +{ + currentQuantityOfNodes = quantityOfNodes; +} + +void SpriteCreateTest::initWithQuantityOfNodes(unsigned int nNodes) +{ + PerformceAllocScene::initWithQuantityOfNodes(nNodes); + + printf("Size of Node: %lu\n", sizeof(Sprite)); + + scheduleUpdate(); +} + +void SpriteCreateTest::update(float dt) +{ + // iterate using fast enumeration protocol + + Sprite **sprites = new Sprite*[quantityOfNodes]; + + CC_PROFILER_START(this->profilerName()); + for( int i=0; iprofilerName()); + + delete [] sprites; +} + +std::string SpriteCreateTest::title() +{ + return "Sprite Create Perf test."; +} + +std::string SpriteCreateTest::subtitle() +{ + return "Sprite Create Perf test. See console"; +} + +const char* SpriteCreateTest::testName() +{ + return "Sprite::create()"; +} + +//////////////////////////////////////////////////////// +// +// SpriteDeallocTest +// +//////////////////////////////////////////////////////// +void SpriteDeallocTest::updateQuantityOfNodes() +{ + currentQuantityOfNodes = quantityOfNodes; +} + +void SpriteDeallocTest::initWithQuantityOfNodes(unsigned int nNodes) +{ + PerformceAllocScene::initWithQuantityOfNodes(nNodes); + + printf("Size of Node: %lu\n", sizeof(Sprite)); + + scheduleUpdate(); +} + +void SpriteDeallocTest::update(float dt) +{ + // iterate using fast enumeration protocol + + Sprite **sprites = new Sprite*[quantityOfNodes]; + + for( int i=0; iinit(); + } + + CC_PROFILER_START(this->profilerName()); + for( int i=0; irelease(); + CC_PROFILER_STOP(this->profilerName()); + + delete [] sprites; +} + +std::string SpriteDeallocTest::title() +{ + return "Sprite Dealloc Perf test."; +} + +std::string SpriteDeallocTest::subtitle() +{ + return "Sprite Dealloc Perf test. See console"; +} + +const char* SpriteDeallocTest::testName() +{ + return "Sprite::~Sprite()"; +} + +///---------------------------------------- +void runAllocPerformanceTest() +{ + auto scene = createFunctions[g_curCase](); + scene->initWithQuantityOfNodes(kNodesIncrease); + + Director::getInstance()->replaceScene(scene); + scene->release(); +} diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.h b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.h new file mode 100644 index 0000000000..fd77234522 --- /dev/null +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.h @@ -0,0 +1,100 @@ +/* + * + */ +#ifndef __PERFORMANCE_ALLOC_TEST_H__ +#define __PERFORMANCE_ALLOC_TEST_H__ + +#include "PerformanceTest.h" +#include "support/CCProfiling.h" + +class AllocBasicLayer : public PerformBasicLayer +{ +public: + AllocBasicLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0); + + virtual void showCurrentTest(); +}; + +class PerformceAllocScene : public Scene +{ +public: + virtual void initWithQuantityOfNodes(unsigned int nNodes); + virtual std::string title(); + virtual std::string subtitle(); + virtual void updateQuantityOfNodes() = 0; + + const char* profilerName(); + void updateProfilerName(); + + // for the profiler + virtual const char* testName() = 0; + + void updateQuantityLabel(); + + int getQuantityOfNodes() { return quantityOfNodes; } + + void dumpProfilerInfo(float dt); + + // overrides + virtual void onExitTransitionDidStart() override; + virtual void onEnterTransitionDidFinish() override; + +protected: + char _profilerName[256]; + int lastRenderedCount; + int quantityOfNodes; + int currentQuantityOfNodes; +}; + +class NodeCreateTest : public PerformceAllocScene +{ +public: + virtual void updateQuantityOfNodes(); + virtual void initWithQuantityOfNodes(unsigned int nNodes); + virtual void update(float dt); + virtual const char* testName(); + + std::string title(); + std::string subtitle(); +}; + +class NodeDeallocTest : public PerformceAllocScene +{ +public: + virtual void updateQuantityOfNodes(); + virtual void initWithQuantityOfNodes(unsigned int nNodes); + virtual void update(float dt); + virtual const char* testName(); + + std::string title(); + std::string subtitle(); +}; + +class SpriteCreateTest : public PerformceAllocScene +{ +public: + virtual void updateQuantityOfNodes(); + virtual void initWithQuantityOfNodes(unsigned int nNodes); + virtual void update(float dt); + virtual const char* testName(); + + std::string title(); + std::string subtitle(); +}; + +class SpriteDeallocTest : public PerformceAllocScene +{ +public: + virtual void updateQuantityOfNodes(); + virtual void initWithQuantityOfNodes(unsigned int nNodes); + virtual void update(float dt); + virtual const char* testName(); + + std::string title(); + std::string subtitle(); +}; + + +void runAllocPerformanceTest(); + +#endif // __PERFORMANCE_ALLOC_TEST_H__ diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp index 20bd0e4c86..69e10a75eb 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp @@ -5,6 +5,7 @@ #include "PerformanceSpriteTest.h" #include "PerformanceTextureTest.h" #include "PerformanceTouchesTest.h" +#include "PerformanceAllocTest.h" enum { @@ -17,11 +18,12 @@ struct { std::function callback; } g_testsName[] = { - { "PerformanceNodeChildrenTest", [](Object*sender){runNodeChildrenTest();} }, - { "PerformanceParticleTest",[](Object*sender){runParticleTest();} }, - { "PerformanceSpriteTest",[](Object*sender){runSpriteTest();} }, - { "PerformanceTextureTest",[](Object*sender){runTextureTest();} }, - { "PerformanceTouchesTest",[](Object*sender){runTouchesTest();} }, + { "Alloc Test", [](Object*sender){runAllocPerformanceTest(); } }, + { "NodeChildren Test", [](Object*sender){runNodeChildrenTest();} }, + { "Particle Test",[](Object*sender){runParticleTest();} }, + { "Sprite Perf Test",[](Object*sender){runSpriteTest();} }, + { "Texture Perf Test",[](Object*sender){runTextureTest();} }, + { "Touches Perf Test",[](Object*sender){runTouchesTest();} }, }; static const int g_testMax = sizeof(g_testsName)/sizeof(g_testsName[0]); diff --git a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id index ef847642e4..a29561203f 100644 --- a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -a9fdccd58c6cf8ce3cb5d00ea294ef9ff216d439 \ No newline at end of file +c29e3bbc173f7da0b308c5f8e18a44136f96c966 \ No newline at end of file From 0131ecf7057dafdde56cb24fc9266f9435f10590 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 6 Sep 2013 11:44:10 +0800 Subject: [PATCH 2/4] add PerformanceAllocTest.cpp/h to Android.mk and linux project setting --- samples/Cpp/TestCpp/Android.mk | 1 + samples/Cpp/TestCpp/proj.linux/Makefile | 1 + 2 files changed, 2 insertions(+) diff --git a/samples/Cpp/TestCpp/Android.mk b/samples/Cpp/TestCpp/Android.mk index e3036d7e67..68106673cd 100644 --- a/samples/Cpp/TestCpp/Android.mk +++ b/samples/Cpp/TestCpp/Android.mk @@ -89,6 +89,7 @@ Classes/MutiTouchTest/MutiTouchTest.cpp \ Classes/NodeTest/NodeTest.cpp \ Classes/ParallaxTest/ParallaxTest.cpp \ Classes/ParticleTest/ParticleTest.cpp \ +Classes/PerformanceTest/PerformanceAllocTest.cpp \ Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp \ Classes/PerformanceTest/PerformanceParticleTest.cpp \ Classes/PerformanceTest/PerformanceSpriteTest.cpp \ diff --git a/samples/Cpp/TestCpp/proj.linux/Makefile b/samples/Cpp/TestCpp/proj.linux/Makefile index 5104b1ace8..e3b33bb427 100644 --- a/samples/Cpp/TestCpp/proj.linux/Makefile +++ b/samples/Cpp/TestCpp/proj.linux/Makefile @@ -73,6 +73,7 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ ../Classes/NodeTest/NodeTest.cpp \ ../Classes/ParallaxTest/ParallaxTest.cpp \ ../Classes/ParticleTest/ParticleTest.cpp \ + ../Classes/PerformanceTest/PerformanceAllocTest.cpp \ ../Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp \ ../Classes/PerformanceTest/PerformanceParticleTest.cpp \ ../Classes/PerformanceTest/PerformanceSpriteTest.cpp \ From 1071ab9d3764fe7185f5019b24cf6bcbc64425dd Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 5 Sep 2013 21:35:15 -0700 Subject: [PATCH 3/4] Adds a new test: sprite with image --- .../PerformanceTest/PerformanceAllocTest.cpp | 61 +++++++++++++++++-- .../PerformanceTest/PerformanceAllocTest.h | 12 ++++ 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp index 09fbd94d7e..1ee79098e8 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp @@ -36,6 +36,7 @@ static std::function createFunctions[] = { CL(NodeCreateTest), CL(NodeDeallocTest), + CL(SpriteCreateEmptyTest), CL(SpriteCreateTest), CL(SpriteDeallocTest), }; @@ -318,6 +319,56 @@ const char* NodeDeallocTest::testName() return "Node::~Node()"; } +//////////////////////////////////////////////////////// +// +// SpriteCreateEmptyTest +// +//////////////////////////////////////////////////////// +void SpriteCreateEmptyTest::updateQuantityOfNodes() +{ + currentQuantityOfNodes = quantityOfNodes; +} + +void SpriteCreateEmptyTest::initWithQuantityOfNodes(unsigned int nNodes) +{ + PerformceAllocScene::initWithQuantityOfNodes(nNodes); + + printf("Size of Node: %lu\n", sizeof(Sprite)); + + scheduleUpdate(); +} + +void SpriteCreateEmptyTest::update(float dt) +{ + // iterate using fast enumeration protocol + + Sprite **sprites = new Sprite*[quantityOfNodes]; + + Sprite::create("Images/grossini.png"); + + CC_PROFILER_START(this->profilerName()); + for( int i=0; iprofilerName()); + + delete [] sprites; +} + +std::string SpriteCreateEmptyTest::title() +{ + return "Create Empty Sprite"; +} + +std::string SpriteCreateEmptyTest::subtitle() +{ + return "Create Empty Sprite Perf test. See console"; +} + +const char* SpriteCreateEmptyTest::testName() +{ + return "Sprite::create(void)"; +} + //////////////////////////////////////////////////////// // // SpriteCreateTest @@ -343,9 +394,11 @@ void SpriteCreateTest::update(float dt) Sprite **sprites = new Sprite*[quantityOfNodes]; + Sprite::create("Images/grossini.png"); + CC_PROFILER_START(this->profilerName()); for( int i=0; iprofilerName()); delete [] sprites; @@ -353,17 +406,17 @@ void SpriteCreateTest::update(float dt) std::string SpriteCreateTest::title() { - return "Sprite Create Perf test."; + return "Create Sprite."; } std::string SpriteCreateTest::subtitle() { - return "Sprite Create Perf test. See console"; + return "Create Empty Sprite. See console"; } const char* SpriteCreateTest::testName() { - return "Sprite::create()"; + return "Sprite::create(\"image\")"; } //////////////////////////////////////////////////////// diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.h b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.h index fd77234522..5c822fc95a 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.h +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.h @@ -70,6 +70,18 @@ public: std::string subtitle(); }; +class SpriteCreateEmptyTest : public PerformceAllocScene +{ +public: + virtual void updateQuantityOfNodes(); + virtual void initWithQuantityOfNodes(unsigned int nNodes); + virtual void update(float dt); + virtual const char* testName(); + + std::string title(); + std::string subtitle(); +}; + class SpriteCreateTest : public PerformceAllocScene { public: From 1664d3503d50488b14ee9630328c3a68c4b08db3 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 6 Sep 2013 12:51:37 +0800 Subject: [PATCH 4/4] add PerformanceAllocTest.cpp/h to vs project and fix some compiling errors --- .../Classes/PerformanceTest/PerformanceAllocTest.cpp | 6 +++--- .../Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp | 6 +++--- samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj | 1 + samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters | 3 +++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp index 09fbd94d7e..5f1f04316e 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp @@ -122,7 +122,7 @@ void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes) updateQuantityOfNodes(); updateProfilerName(); CC_PROFILER_PURGE_ALL(); - srandom(0); + srand(0); }); decrease->setColor(Color3B(0,200,20)); auto increase = MenuItemFont::create(" + ", [&](Object *sender) { @@ -134,7 +134,7 @@ void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes) updateQuantityOfNodes(); updateProfilerName(); CC_PROFILER_PURGE_ALL(); - srandom(0); + srand(0); }); increase->setColor(Color3B(0,200,20)); @@ -155,7 +155,7 @@ void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes) updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); - srandom(0); + srand(0); } std::string PerformceAllocScene::title() diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index 570a72463d..6d1391b578 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -153,7 +153,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) updateQuantityOfNodes(); updateProfilerName(); CC_PROFILER_PURGE_ALL(); - srandom(0); + srand(0); }); decrease->setColor(Color3B(0,200,20)); auto increase = MenuItemFont::create(" + ", [&](Object *sender) { @@ -165,7 +165,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) updateQuantityOfNodes(); updateProfilerName(); CC_PROFILER_PURGE_ALL(); - srandom(0); + srand(0); }); increase->setColor(Color3B(0,200,20)); @@ -186,7 +186,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); - srandom(0); + srand(0); } std::string NodeChildrenMainScene::title() diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj index f85811054a..d954e1eb21 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj @@ -157,6 +157,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O + diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters index a3d6cbc6c9..0580a13014 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters @@ -555,6 +555,9 @@ Classes\LabelTest + + Classes\PerformanceTest +