Пример #1
0
int RunEdit::processEvent (const Event& event)
{
    switch (event.key) {

    case KB_F1:
    case KB_ALT_B:
        insBaseFile ();
        break;

    case KB_F2:
    case KB_ALT_F:
        insFile ();
        break;

    case KB_F3:
    case KB_ALT_D:
        insDir ();
        break;

    case KB_F4:
    case KB_ALT_P:
        insPrompt ();
        break;

    case KB_F5:
    case KB_ALT_M:
        insAllFiles ();
        break;

    case KB_F6:
    case KB_ALT_Q:
        insAllFilesQuoted ();
        break;

    case KB_F7:
    case KB_ALT_I:
        insImmediateReturn ();
        break;

    case KB_F8:
    case KB_ALT_A:
        insAutoRefresh ();
        break;

    case KB_F9:
    case KB_ALT_V:
        insDrive ();
        break;

    case KB_F10:
    case KB_ALT_T:
        insPathOnly ();
        break;

    case KB_CTRL_ENTER:
        sendEvent (Event (KB_ENTER));
        mExitKey = KB_CTRL_ENTER;
        break;

    default:
        return Edit::processEvent (event);
    }

    return 1;
}
Пример #2
0
void Performance::run(
        std::vector<TC *> algs,        //< Algorithms to be executed
        std::vector<Input> changes, //< Changes as defined in project description
        std::string output_prefix)    //< e.g. output/changefile3-ins.stat
{

    // Open output streams
    std::ofstream insFile(outputDir + output_prefix + insSuffix);
    std::ofstream delFile(outputDir + output_prefix + delSuffix);
    std::ofstream queryFile(outputDir + output_prefix + querySuffix);

    //
    unsigned int querySize;
    long long cpuClock;
    for (auto &alg : algs) {
        const char *name = alg->get_name();
        std::string strName(name, strlen(name));
        std::ofstream queryOutFile(outputDir + output_prefix + strName + queryOutSuffix);
        for (auto &change : changes) {
            switch (change.type) {
                case 4:
                    alg->jump(change.state);
                    break;
                case 3:
                    alg->init(change.i);
                    break;
                case 2:
                    // Reset counters
                    ioctl(this->fd, PERF_EVENT_IOC_RESET, PERF_IOC_FLAG_GROUP);
                    // Start counting
                    ioctl(this->fd, PERF_EVENT_IOC_ENABLE, PERF_IOC_FLAG_GROUP);
                    // Run query
                    querySize = alg->query();
                    // Stop counting
                    ioctl(this->fd, PERF_EVENT_IOC_DISABLE, PERF_IOC_FLAG_GROUP);
                    // Get CPU clock count
                    cpuClock = _get(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK);
                    // Write cpu time
                    queryFile << name << "," << cpuClock << "\n";
                    // Write output (for correctness)
                    queryOutFile << querySize << "\n";
                    break;
                case 1:
                    // Reset counters
                    ioctl(this->fd, PERF_EVENT_IOC_RESET, PERF_IOC_FLAG_GROUP);
                    // Start counting
                    ioctl(this->fd, PERF_EVENT_IOC_ENABLE, PERF_IOC_FLAG_GROUP);
                    // Run query
                    alg->del(change.i, change.j);
                    // Stop counting
                    ioctl(this->fd, PERF_EVENT_IOC_DISABLE, PERF_IOC_FLAG_GROUP);
                    // Get CPU clock count
                    cpuClock = _get(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK);
                    // Write cpu time
                    delFile << name << "," << cpuClock << "\n";
                    break;
                case 0:
                    // Reset counters
                    ioctl(this->fd, PERF_EVENT_IOC_RESET, PERF_IOC_FLAG_GROUP);
                    // Start counting
                    ioctl(this->fd, PERF_EVENT_IOC_ENABLE, PERF_IOC_FLAG_GROUP);
                    // Run query
                    alg->ins(change.i, change.j);
                    // Stop counting
                    ioctl(this->fd, PERF_EVENT_IOC_DISABLE, PERF_IOC_FLAG_GROUP);
                    // Get CPU clock count
                    cpuClock = _get(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK);
                    // Write cpu time
                    insFile << name << "," << cpuClock << "\n";
                    break;
                default:
                    std::cout << "ERROR!!" << std::endl;
                    // Close all files
                    queryOutFile.close();
                    insFile.close();
                    delFile.close();
                    queryFile.close();
                    return;
            }
        }
        queryOutFile.close();
    }
    insFile.close();
    delFile.close();
    queryFile.close();
}