void SpriteMainScene::endStat(float dt)
{
    unschedule(CC_SCHEDULE_SELECTOR(SpriteMainScene::endStat));
    isStating = false;
    
    // record test data
    auto typeStr = getTestCaseName();
    auto avgStr = genStr("%.2f", (float) statCount / totalStatTime);
    Profile::getInstance()->addTestResult(genStrVector(genStr("%d", _quantityNodes).c_str(), typeStr.c_str(),
                                                       genStr("%d", _subtestNumber).c_str(), nullptr),
                                          genStrVector(avgStr.c_str(), genStr("%.2f", minFrameRate).c_str(),
                                                       genStr("%.2f", maxFrameRate).c_str(), nullptr));
    
    // check the auto test is end or not
    int autoTestCount = sizeof(autoTestSpriteCounts) / sizeof(int);
    if (autoTestIndex >= (autoTestCount - 1) &&
        _subtestNumber >= MAX_SUB_TEST_NUM)
    {
        // auto test end
        Profile::getInstance()->testCaseEnd();
        setAutoTesting(false);
        return;
    }
    
    if (autoTestIndex >= (autoTestCount - 1))
    {
        autoTestIndex = 0;
        _subtestNumber++;
    }
    else
    {
        autoTestIndex++;
    }
    doAutoTest();
}
void NodeChildrenMainScene::dumpProfilerInfo(float dt)
{
    CC_PROFILER_DISPLAY_TIMERS();
    
    if (this->isAutoTesting()) {
        // record the test result to class Profile
        auto timer = Profiler::getInstance()->_activeTimers.at(_profilerName);
        auto numStr = genStr("%d", quantityOfNodes);
        auto avgStr = genStr("%ldµ", timer->_averageTime2);
        auto minStr = genStr("%ldµ", timer->minTime);
        auto maxStr = genStr("%ldµ", timer->maxTime);
        Profile::getInstance()->addTestResult(genStrVector(getTestCaseName().c_str(), numStr.c_str(), nullptr),
                                              genStrVector(avgStr.c_str(), minStr.c_str(), maxStr.c_str(), nullptr));
        
        auto testsSize = sizeof(autoTestNodesNums)/sizeof(int);
        if (autoTestIndex >= (testsSize - 1)) {
            // if it's the last one of auto test. End the auto test.
            this->setAutoTesting(false);
            Profile::getInstance()->testCaseEnd();
        }
        else
        {
            // update the auto test index
            autoTestIndex++;
            quantityOfNodes = autoTestNodesNums[autoTestIndex];
            updateQuantityLabel();
            updateQuantityOfNodes();
            updateProfilerName();
            CC_PROFILER_PURGE_ALL();
        }
    }
}
void ParticleMainScene::endStat(float dt)
{
    unschedule(CC_SCHEDULE_SELECTOR(ParticleMainScene::endStat));
    isStating = false;

    // record test data
    std::string tf;
    switch (subtestNumber) {
        case 1:
            tf = "RGBA8888";
            break;
        case 2:
            tf = "RGBA4444";
            break;
        case 3:
            tf = "A8";
            break;
        default:
            tf = "unknown";
            break;
    }
    auto avgStr = genStr("%.2f", (float) statCount / totalStatTime);
    Profile::getInstance()->addTestResult(genStrVector(genStr("%d", particleSize).c_str(), tf.c_str(),
                                                       genStr("%d", quantityParticles).c_str(), nullptr),
                                          genStrVector(avgStr.c_str(), genStr("%.2f", minFrameRate).c_str(),
                                                       genStr("%.2f", maxFrameRate).c_str(), nullptr));

    // check the auto test is end or not
    int autoTestCount = sizeof(autoTestParticleCounts) / sizeof(int);
    if (autoTestIndex >= (autoTestCount - 1) &&
        subtestNumber >= MAX_SUB_TEST_NUM)
    {
        // auto test end
        Profile::getInstance()->testCaseEnd();
        setAutoTesting(false);
        return;
    }

    if (autoTestIndex >= (autoTestCount - 1))
    {
        autoTestIndex = 0;
        subtestNumber++;
    }
    else
    {
        autoTestIndex++;
    }
    doAutoTest();
}
void ScenarioTest::endStat(float dt)
{
    unschedule(CC_SCHEDULE_SELECTOR(ScenarioTest::endStat));
    isStating = false;
    
    // record test data
    auto avgStr = genStr("%.2f", (float) statCount / totalStatTime);
    Profile::getInstance()->addTestResult(genStrVector(genStr("%d", _spriteArray.size()).c_str(),
                                                       genStr("%d", _particleNumber).c_str(),
                                                       genStr("%d", _parsysArray.size()).c_str(),
                                                       nullptr),
                                          genStrVector(avgStr.c_str(), genStr("%.2f", minFrameRate).c_str(),
                                                       genStr("%.2f", maxFrameRate).c_str(), nullptr));

    // check the auto test is end or not
    int autoTestCount = sizeof(autoTestCounts) / sizeof(TestCaseInfo);
    if (autoTestIndex >= (autoTestCount - 1))
    {
        // auto test end
        Profile::getInstance()->testCaseEnd();
        setAutoTesting(false);
        return;
    }

    autoTestIndex++;
    doAutoTest();
}
Example #5
0
    vector<vector<string> > findLadders(string start, string end, unordered_set<string> &dict) {
        
        vector<vector<string> > results;
        queue<vector<int> > q;
        unordered_map<string, int> pos;
        vector<string> words;
        words.push_back(start);
        buildMap(dict, pos, words);
        vector<int> r;
        bool reached = false;

        r.push_back(0);
        q.push(r);
        vector<int> seperator;
        seperator.push_back(-1);
        q.push(seperator);

        while(!q.empty()){
            vector<int> cur = q.front();
            q.pop();
            if(cur[0] == -1){
                if(reached || q.empty()){
                    break;
                }
                q.push(seperator);
                continue;
            }
            string s = words[cur.back()];
            for(int i = 0; i < s.size(); i++){
                for(char c = 'a'; c <= 'z'; c++){
                    string tmp = s;
                    tmp[i] = c;
                    if(tmp == end){
                        results.push_back(genStr(cur, words, end));
                        reached = true;
                    }
                    else if(dict.count(tmp) > 0 && notUsed(cur, pos[tmp])){
                        cur.push_back(pos[tmp]);
                        q.push(cur);
                        cur.pop_back();
                    }
                }
            }
        } 

        return results;
    }
Example #6
0
int main(int argc, char* argv[]) {
    srand(time(NULL));

    setlocale(LC_ALL, "en_US.utf8");
    initscr();
    raw();
    noecho();
    start_color();
    init_pair(FAIL, COLOR_RED, COLOR_BLACK);

    WINDOW *typeWin = newwin(4, COLS, 0, 0);
    box(typeWin, 0, 0);
    refresh();
    typeStr(typeWin, genStr("data-russian", 50));

    endwin();
    return 0;
}