mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 16:00:39 +01:00
[v1.05] Use UNKNOWN_DATA instead of -1 in frequency measurement
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
#include <linux/perf_event.h>
|
#include <linux/perf_event.h>
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "cpu.h"
|
||||||
|
|
||||||
static long
|
static long
|
||||||
perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
|
perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
|
||||||
@@ -158,7 +159,7 @@ uint64_t get_num_iters_from_freq(double frequency) {
|
|||||||
int64_t measure_max_frequency(uint32_t core) {
|
int64_t measure_max_frequency(uint32_t core) {
|
||||||
if (!bind_to_cpu(core)) {
|
if (!bind_to_cpu(core)) {
|
||||||
printErr("Failed binding the process to CPU %d", core);
|
printErr("Failed binding the process to CPU %d", core);
|
||||||
return -1;
|
return UNKNOWN_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, get very rough estimation of clock cycle to
|
// First, get very rough estimation of clock cycle to
|
||||||
@@ -166,11 +167,11 @@ int64_t measure_max_frequency(uint32_t core) {
|
|||||||
double estimation_freq, frequency;
|
double estimation_freq, frequency;
|
||||||
uint64_t iters = 100000;
|
uint64_t iters = 100000;
|
||||||
if (measure_freq_iters(iters, core, &estimation_freq) == -1)
|
if (measure_freq_iters(iters, core, &estimation_freq) == -1)
|
||||||
return -1;
|
return UNKNOWN_DATA;
|
||||||
|
|
||||||
if (estimation_freq <= 0.0) {
|
if (estimation_freq <= 0.0) {
|
||||||
printErr("First frequency measurement yielded an invalid value: %f", estimation_freq);
|
printErr("First frequency measurement yielded an invalid value: %f", estimation_freq);
|
||||||
return -1;
|
return UNKNOWN_DATA;
|
||||||
}
|
}
|
||||||
iters = get_num_iters_from_freq(estimation_freq);
|
iters = get_num_iters_from_freq(estimation_freq);
|
||||||
printWarn("Running frequency measurement with %ld iterations on core %d...", iters, core);
|
printWarn("Running frequency measurement with %ld iterations on core %d...", iters, core);
|
||||||
@@ -181,7 +182,7 @@ int64_t measure_max_frequency(uint32_t core) {
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
if (measure_freq_iters(iters, core, &frequency) == -1)
|
if (measure_freq_iters(iters, core, &frequency) == -1)
|
||||||
return -1;
|
return UNKNOWN_DATA;
|
||||||
|
|
||||||
// Clean screen once measurement is finished
|
// Clean screen once measurement is finished
|
||||||
printf("\r%*c\r", (int) strlen(frequency_banner), ' ');
|
printf("\r%*c\r", (int) strlen(frequency_banner), ' ');
|
||||||
|
|||||||
Reference in New Issue
Block a user