コード例 #1
0
ファイル: intel_cpus.cpp プロジェクト: goodyoga/powertop
char * nhm_cpu::fill_pstate_line(int line_nr, char *buffer)
{
	if (total_stamp ==0) {
		unsigned int i;
		for (i = 0; i < pstates.size(); i++)
			total_stamp += pstates[i]->time_after;
		if (total_stamp == 0)
			total_stamp = 1;
	}

	if (line_nr == LEVEL_HEADER) {
		sprintf(buffer,_(" CPU %i"), number);
		return buffer;
	}

	if (line_nr == LEVEL_C0) {
		double F;
		F = 1.0 * (tsc_after - tsc_before) * (aperf_after - aperf_before) / (mperf_after - mperf_before) / time_factor * 1000;
		hz_to_human(F, buffer, 1);
		return buffer;
	}
	if (line_nr >= (int)pstates.size() || line_nr < 0)
		return buffer;

	sprintf(buffer," %5.1f%% ", percentage(1.0* (pstates[line_nr]->time_after) / total_stamp));
	return buffer;

}
コード例 #2
0
ファイル: cpu_package.cpp プロジェクト: vcgomes/powertop
void cpu_package::account_freq(uint64_t freq, uint64_t duration)
{
    struct frequency *state = NULL;
    unsigned int i;

    for (i = 0; i < pstates.size(); i++) {
        if (freq == pstates[i]->freq) {
            state = pstates[i];
            break;
        }
    }


    if (!state) {
        state = new(std::nothrow) struct frequency;

        if (!state)
            return;

        memset(state, 0, sizeof(*state));

        pstates.push_back(state);

        state->freq = freq;
        hz_to_human(freq, state->human_name);
        if (freq == 0)
            strcpy(state->human_name, _("Idle"));
        if (is_turbo(freq, max_frequency, max_minus_one_frequency))
            sprintf(state->human_name, _("Turbo Mode"));
        state->after_count = 1;
    }

    state->time_after += duration;

}