PuzzleSDK
Material_parsePerformance类 参考

#include <MaterialSystemTest.h>

+ 类 Material_parsePerformance 继承关系图:
+ Material_parsePerformance 的协作图:

Public 成员函数

 CREATE_FUNC (Material_parsePerformance)
 
virtual void onEnter () override
 
virtual std::string subtitle () const override
 
void parsingTesting (unsigned int count)
 
- Public 成员函数 继承自 MaterialSystemBaseTest
virtual std::string title () const override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 

Protected 属性

unsigned int _maxParsingCoumt
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 

详细描述

在文件 MaterialSystemTest.h125 行定义.

成员函数说明

◆ CREATE_FUNC()

Material_parsePerformance::CREATE_FUNC ( Material_parsePerformance  )

◆ onEnter()

void Material_parsePerformance::onEnter ( )
overridevirtual

重载 TestCase .

在文件 MaterialSystemTest.cpp402 行定义.

403{
405
406 _maxParsingCoumt = 5e3;
407
408 auto screenSize = Director::getInstance()->getWinSize();
409
410 ui::Slider* slider = ui::Slider::create();
411 slider->loadBarTexture("cocosui/sliderTrack.png");
412 slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
413 slider->loadProgressBarTexture("cocosui/sliderProgress.png");
414 slider->setPercent(50);
415
416 slider->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 3.0f));
417 slider->addEventListener([&](Ref* sender, ui::Slider::EventType type) {
418
419 if (type == ui::Slider::EventType::ON_SLIDEBALL_UP)
420 {
421 ui::Slider* slider = dynamic_cast<ui::Slider*>(sender);
422 float p = slider->getPercent() / 100.0f;
423 slider->setTouchEnabled(false);
424 CCLOG("Will parsing material %d times", (int)(p * _maxParsingCoumt));
425 Label* label = dynamic_cast<Label*>(this->getChildByTag(SHOW_LEBAL_TAG));
426 if(label)
427 {
428 label->setString("Testing start!");
429 }
430 this->scheduleOnce(
431 [this, p, slider](float)
432 {
434 slider->setTouchEnabled(true);
435 },
436 1.0, "schedule test parsing");
437
438 }
439 });
440
441 addChild(slider);
442
443 auto label = Label::createWithSystemFont("Max parsing count is 10000, which may crash because of high memory consumption.", "Helvetica", 10);
444 label->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f - 20));
445 addChild(label);
446 label = Label::createWithSystemFont("Slide to test parsing performance", "Helvetica", 10);
447 label->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f));
448 addChild(label);
449
450 label = Label::createWithSystemFont("", "Helvetica", 10);
451 label->setPosition(Vec2(screenSize.width / 2.0f, screenSize.height / 2.0f + 20));
452 label->setTag(SHOW_LEBAL_TAG);
453 addChild(label);
454
455}
const int SHOW_LEBAL_TAG
void parsingTesting(unsigned int count)
virtual void onEnter() override
Definition: BaseTest.cpp:430

引用了 _maxParsingCoumt, TestCase::onEnter(), parsingTesting() , 以及 SHOW_LEBAL_TAG.

+ 函数调用图:

◆ parsingTesting()

void Material_parsePerformance::parsingTesting ( unsigned int  count)

在文件 MaterialSystemTest.cpp457 行定义.

458{
459 std::clock_t begin = std::clock();
460
461 for (unsigned int i = 0; i < count; i++)
462 {
463 Material::createWithFilename("Materials/2d_effects.material");
464 Material::createWithFilename("Materials/3d_effects.material");
465 }
466
467 std::clock_t end = std::clock();
468 double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
469 Label* label = dynamic_cast<Label*>(this->getChildByTag(SHOW_LEBAL_TAG));
470 if(label)
471 {
472 std::string str = StringUtils::format("Testing completed! Took: %.3f seconds for parsing material %d times.", elapsed_secs, count);
473 label->setString(str);
474
475 CCLOG("Took: %.3f seconds for parsing material %d times.", elapsed_secs, count);
476 }
477}

引用了 SHOW_LEBAL_TAG.

被这些函数引用 onEnter().

+ 这是这个函数的调用关系图:

◆ subtitle()

std::string Material_parsePerformance::subtitle ( ) const
overridevirtual

重载 TestCase .

在文件 MaterialSystemTest.cpp479 行定义.

480{
481 return "Testing parsing performance";
482}

类成员变量说明

◆ _maxParsingCoumt

unsigned int Material_parsePerformance::_maxParsingCoumt
protected

在文件 MaterialSystemTest.h134 行定义.

被这些函数引用 onEnter().


该类的文档由以下文件生成: