Ejemplo n.º 1
0
        std::shared_ptr<T> pop()
        {
            std::lock_guard<std::mutex> _lock_(m_mutex);
            if(m_queue.empty())
            {
                return std::shared_ptr<T>();
            }
            else
            {
                std::shared_ptr<T> tmpm(std::move(m_queue.front()));
                m_queue.pop_front();

                return tmpm;
            }
        }
Ejemplo n.º 2
0
void PfProfiler::process()
{
    uint64_t maxMissCount=0, maxMissPath=0;
    uint64_t maxICount=0, maxICountPath=0;
    uint64_t minMissCount=(uint64_t)-1, minMissPath=0;
    uint64_t minICount=(uint64_t)-1, minICountPath=0;

    std::ofstream statsFile;
    statsFile.open(CpOutFile.c_str());

    if (TerminatedPaths) {
        statsFile << "#This report shows data for only those paths that generated a test case" << std::endl;
    }


    PathBuilder pb(&m_Parser);
    m_Parser.parse(m_FileName);

    ModuleCache mc(&pb);
    CacheProfiler cp(&mc, &pb);
    TestCase tc(&pb);
    InstructionCounter ic(&pb);

    pb.processTree();

    unsigned pathNum = 0;

    PathSet paths;
    pb.getPaths(paths);

    PathSet::iterator pit;
    for(pit = paths.begin(); pit != paths.end(); ++pit) {
        statsFile << "========== Path " << pathNum << " ========== "<<std::endl;
        std::cout << std::dec << "Path " << pathNum << std::endl;


        TestCaseState *tcs = static_cast<TestCaseState*>(pb.getState(&tc, *pit));
        InstructionCounterState *ics = static_cast<InstructionCounterState*>(pb.getState(&ic, *pit));

        if (TerminatedPaths) {
            if (!tcs || !tcs->hasInputs()) {
                pathNum++;
                continue;
            }
        }

        if (ics) {
            ics->printCounter(statsFile);
        }else {
            statsFile << "No instruction count in the trace file for the current path" << std::endl;
        }

        if (tcs) {
            tcs->printInputs(statsFile);
        }else {
            statsFile << "No test case in the trace file for the current path" << std::endl;
        }

        TopMissesPerModule tmpm(&m_binaries, &cp);

        tmpm.setFilteredProcess(CPFilterProcess);
        tmpm.setFilteredModule(FilterModule);
        tmpm.setMinMissThreshold(CPMinMissCountFilter);

        tmpm.computeStats(*pit);
        statsFile << "Total misses on this path: " << std::dec << tmpm.getTotalMisses() << std::endl;

        tmpm.printAggregatedStatistics(statsFile);
        tmpm.print(statsFile);

        if (ics) {
            if (ics->getCount() > maxICount) {
                maxICount = ics->getCount();
                maxICountPath = pathNum;
            }

            if (ics->getCount() < minICount) {
                minICount = ics->getCount();
                minICountPath = pathNum;
            }
        }

        if (tmpm.getTotalMisses() > maxMissCount) {
            maxMissCount = tmpm.getTotalMisses();
            maxMissPath = pathNum;
        }

        if (tmpm.getTotalMisses() < minMissCount) {
            minMissCount = tmpm.getTotalMisses();
            minMissPath = pathNum;
        }


        ++pathNum;
        statsFile << std::endl;
    }


    statsFile << "----------------------------------" << std::endl << std::dec;
    statsFile << "Miss count        - Max:" << std::setw(10) << maxMissCount << " (path " << std::setw(10) << maxMissPath << ") ";
    statsFile << "Min:" << std::setw(10)<< minMissCount << "(path " << std::setw(10) << minMissPath << ")" << std::endl;

    statsFile << "Instruction count - Max:" << std::setw(10) << maxICount << " (path "<< std::setw(10) << maxICountPath << ") ";
    statsFile << "Min:"<< std::setw(10) << minICount << "(path " << std::setw(10) << minICountPath << ")" << std::endl;

    return;
}