diff options
author | Ondrej Čerman | 2019-06-19 00:06:34 +0200 |
---|---|---|
committer | Ondrej Čerman | 2019-06-19 00:06:34 +0200 |
commit | b1dd2f531524d64357775b6dbcfde9474eb740c4 (patch) | |
tree | f8d621fca67221ef40bc061dd39417e51ea05633 /src/ss | |
parent | d585178609b19406fd78ae11ddb4209a9a66f365 (diff) |
Added min/max columns
Diffstat (limited to 'src/ss')
-rw-r--r-- | src/ss/msr.c | 26 | ||||
-rw-r--r-- | src/ss/zenpower.c | 27 |
2 files changed, 45 insertions, 8 deletions
diff --git a/src/ss/msr.c b/src/ss/msr.c index 0085363..e3c9198 100644 --- a/src/ss/msr.c +++ b/src/ss/msr.c @@ -25,7 +25,11 @@ gulong *core_eng_b = NULL; gulong *core_eng_a = NULL; gfloat package_power; +gfloat package_power_min; +gfloat package_power_max; gfloat *core_power; +gfloat *core_power_min; +gfloat *core_power_max; static guint get_core_count() { guint eax = 0, ebx = 0, ecx = 0, edx = 0; @@ -87,6 +91,7 @@ gulong get_core_energy(gint core) { gboolean msr_init() { int i; + size_t sz; if (!check_zen()) return FALSE; @@ -107,6 +112,14 @@ gboolean msr_init() { core_eng_b = malloc(cores * sizeof (gulong)); core_eng_a = malloc(cores * sizeof (gulong)); core_power = malloc(cores * sizeof (gfloat)); + core_power_min = malloc(cores * sizeof (gfloat)); + core_power_max = malloc(cores * sizeof (gfloat)); + + msr_update(); + memcpy(core_power_min, core_power, cores * sizeof (gfloat)); + memcpy(core_power_max, core_power, cores * sizeof (gfloat)); + package_power_min = package_power; + package_power_max = package_power; return TRUE; } @@ -128,8 +141,17 @@ void msr_update() { } package_power = (package_eng_a - package_eng_b) * energy_unit / MESUREMENT_TIME; + if (package_power < package_power_min) + package_power_min = package_power; + if (package_power > package_power_max) + package_power_max = package_power; + for (i = 0; i < cores; i++) { core_power[i] = (core_eng_a[i] - core_eng_b[i]) * energy_unit / MESUREMENT_TIME; + if (core_power[i] < core_power_min[i]) + core_power_min[i] = core_power[i]; + if (core_power[i] > core_power_max[i]) + core_power_max[i] = core_power[i]; } } @@ -141,6 +163,8 @@ GSList* msr_get_sensors() { data = sensor_init_new(); data->label = g_strdup("Package Power"); data->value = &package_power; + data->min = &package_power_min; + data->max = &package_power_max; data->printf_format = MSR_PWR_PRINTF_FORMAT; list = g_slist_append(list, data); @@ -148,6 +172,8 @@ GSList* msr_get_sensors() { data = sensor_init_new(); data->label = g_strdup_printf("Core %d Power", i); data->value = &(core_power[i]); + data->min = &(core_power_min[i]); + data->max = &(core_power_max[i]); data->printf_format = MSR_PWR_PRINTF_FORMAT; list = g_slist_append(list, data); } diff --git a/src/ss/zenpower.c b/src/ss/zenpower.c index 7d24bba..e449a3c 100644 --- a/src/ss/zenpower.c +++ b/src/ss/zenpower.c @@ -11,17 +11,19 @@ typedef struct const gchar *printf_format; const double adjust_ratio; float current_value; + float min; + float max; } HwmonSensor; HwmonSensor hwmon_sensors[] = { - {"CPU Temperature (tCtrl)", "temp1_input", " %6.2f°C", 1000.0, 0.0}, - {"CPU Temperature (tDie)", "temp2_input", " %6.2f°C", 1000.0, 0.0}, - {"CPU Core Voltage (SVI2)", "in1_input", " %8.3f V", 1000.0, 0.0}, - {"SOC Voltage (SVI2)", "in2_input", " %8.3f V", 1000.0, 0.0}, - {"CPU Core Current (SVI2)", "curr1_input", " %8.3f A", 1000.0, 0.0}, - {"SOC Current (SVI2)", "curr2_input", " %8.3f A", 1000.0, 0.0}, - {"CPU Core Power (SVI2)", "power1_input", " %8.3f W", 1000000.0, 0.0}, - {"SOC Power (SVI2)", "power2_input", " %8.3f W", 1000000.0, 0.0}, + {"CPU Temperature (tCtrl)", "temp1_input", " %6.2f°C", 1000.0, 0.0, 999.0, 0.0}, + {"CPU Temperature (tDie)", "temp2_input", " %6.2f°C", 1000.0, 0.0, 999.0, 0.0}, + {"CPU Core Voltage (SVI2)", "in1_input", " %8.3f V", 1000.0, 0.0, 999.0, 0.0}, + {"SOC Voltage (SVI2)", "in2_input", " %8.3f V", 1000.0, 0.0, 999.0, 0.0}, + {"CPU Core Current (SVI2)", "curr1_input", " %8.3f A", 1000.0, 0.0, 999.0, 0.0}, + {"SOC Current (SVI2)", "curr2_input", " %8.3f A", 1000.0, 0.0, 999.0, 0.0}, + {"CPU Core Power (SVI2)", "power1_input", " %8.3f W", 1000000.0, 0.0, 999.0, 0.0}, + {"SOC Power (SVI2)", "power2_input", " %8.3f W", 1000000.0, 0.0, 999.0, 0.0}, {0, NULL} }; @@ -66,6 +68,13 @@ void zenpower_update() { for (sensor = hwmon_sensors; sensor->label; sensor++) { if (read_raw_hwmon_value(zenpowerDir, sensor->file, &tmp)){ sensor->current_value = atof(tmp) / sensor->adjust_ratio; + + if (sensor->current_value < sensor->min) + sensor->min = sensor->current_value; + + if (sensor->current_value > sensor->max) + sensor->max = sensor->current_value; + g_free(tmp); } else{ @@ -83,6 +92,8 @@ GSList* zenpower_get_sensors() { data = sensor_init_new(); data->label = g_strdup(sensor->label); data->value = &sensor->current_value; + data->min = &sensor->min; + data->max = &sensor->max; data->printf_format = sensor->printf_format; list = g_slist_append(list, data); } |