diff options
| author | Burt P <pburt0@gmail.com> | 2017-08-10 22:54:33 -0500 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2017-08-11 02:52:21 -0700 | 
| commit | ecdc375c54201be5776ce93d665ee77f74b1167a (patch) | |
| tree | e7f1354d5587a58306a41ecd2b2f73b40e11f2f0 /modules | |
| parent | 242cf8f80c05d655c3ae6ce22ec3751668b11895 (diff) | |
CPU Frequency Desc and benchmark result re-format
Current CPU configurations aren't properly represented in Hardinfo.
For SMT, each hardware thread is still reported as a CPU. Clusters
with different CPU clock rates are not reported. It is common for
ARM to pair a cluster of fast cores with a cluster of slower, but
more power-efficient cores. These changes attempt to address this.
The getProcessorFrequency method now returns the processor's max
frequency for all its cores. While the new
getProcessorFrequencyDesc lists each unique frequency with a prefix
Nx with the count of cores at that freqency.
Benchmark results have been reformated to use the de-prefixed
getProcessorName and getProcessorFrequencyDesc.
As an example from benchmark.conf:
4x AMD Phenom(tm) II X4 940 Processor | 800 MHz
becomes:
AMD Phenom(tm) II X4 940 Processor | 4x 800 MHz
Which, I think, makes much more sense, as it works well with
this kind of thing:
Qualcomm Snapdragon 691 | 4x 1400 MHz + 4x 800 MHz
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/benchmark.c | 14 | ||||
| -rw-r--r-- | modules/devices.c | 75 | ||||
| -rw-r--r-- | modules/devices/arm/processor.c | 14 | 
3 files changed, 85 insertions, 18 deletions
| diff --git a/modules/benchmark.c b/modules/benchmark.c index a32a8e4d..50fddf4d 100644 --- a/modules/benchmark.c +++ b/modules/benchmark.c @@ -192,7 +192,7 @@ static gchar *__benchmark_include_results(gdouble result,  {      GKeyFile *conf;      gchar **machines; -    gchar *path, *results = g_strdup(""), *return_value, *processor_frequency; +    gchar *path, *results = g_strdup(""), *return_value, *processor_frequency, *processor_name;      int i;      conf = g_key_file_new(); @@ -223,7 +223,8 @@ static gchar *__benchmark_include_results(gdouble result,      g_key_file_free(conf);      if (result > 0.0f) { -        processor_frequency = module_call_method("devices::getProcessorFrequency"); +        processor_name = module_call_method("devices::getProcessorName"); +        processor_frequency = module_call_method("devices::getProcessorFrequencyDesc");          return_value = g_strdup_printf("[$ShellParam$]\n"                         "Zebra=1\n"                         "OrderType=%d\n" @@ -233,12 +234,13 @@ static gchar *__benchmark_include_results(gdouble result,                         "ColumnTitle$TextValue=%s\n" /* CPU */                         "ShowColumnHeaders=true\n"                         "[%s]\n" -                       "<big><b>This Machine</b></big>=%.3f|%s MHz\n" +                       "<big><b>%s</b></big>=%.3f|%s\n"                         "%s", order_type, -                       _("CPU Clock"), _("Results"), _("CPU"), +                       _("CPU Config"), _("Results"), _("CPU"),                         benchmark, -                       result, processor_frequency, results); +                       processor_name, result, processor_frequency, results);          g_free(processor_frequency); +        g_free(processor_name);      } else {          return_value = g_strdup_printf("[$ShellParam$]\n"                         "Zebra=1\n" @@ -250,7 +252,7 @@ static gchar *__benchmark_include_results(gdouble result,                         "ShowColumnHeaders=true\n"                         "[%s]\n%s",                         order_type, -                       _("CPU Clock"), _("Results"), _("CPU"), +                       _("CPU Config"), _("Results"), _("CPU"),                         benchmark, results);      }      return return_value; diff --git a/modules/devices.c b/modules/devices.c index b524f908..7246ef9d 100644 --- a/modules/devices.c +++ b/modules/devices.c @@ -126,10 +126,18 @@ gchar *lginterval = NULL;  #include <vendor.h> -static gint proc_cmp(Processor *a, Processor *b) { +static gint proc_cmp_model_name(Processor *a, Processor *b) {      return g_strcmp0(a->model_name, b->model_name);  } +static gint proc_cmp_max_freq(Processor *a, Processor *b) { +    if (a->cpu_mhz == b->cpu_mhz) +        return 0; +    if (a->cpu_mhz > b->cpu_mhz) +        return -1; +    return 1; +} +  gchar *processor_describe_default(GSList * processors)  {      int packs, cores, threads; @@ -161,7 +169,7 @@ gchar *processor_name_default(GSList * processors)      gint cur_count = 0;      tmp = g_slist_copy(processors); -    tmp = g_slist_sort(tmp, (GCompareFunc)proc_cmp); +    tmp = g_slist_sort(tmp, (GCompareFunc)proc_cmp_model_name);      for (l = tmp; l; l = l->next) {          p = (Processor*)l->data; @@ -183,6 +191,7 @@ gchar *processor_name_default(GSList * processors)      return ret;  } +/* TODO: prefix counts are threads when they should be cores. */  gchar *processor_describe_by_counting_names(GSList * processors)  {      gchar *ret = g_strdup(""); @@ -192,7 +201,7 @@ gchar *processor_describe_by_counting_names(GSList * processors)      gint cur_count = 0;      tmp = g_slist_copy(processors); -    tmp = g_slist_sort(tmp, (GCompareFunc)proc_cmp); +    tmp = g_slist_sort(tmp, (GCompareFunc)proc_cmp_model_name);      for (l = tmp; l; l = l->next) {          p = (Processor*)l->data; @@ -266,17 +275,64 @@ gchar *get_processor_count(void)      return g_strdup_printf("%d", g_slist_length(processors));  } -gchar *get_processor_frequency(void) +/* TODO: maybe move into processor.c along with processor_name() etc. + * Could mention the big.LITTLE cluster arangement for ARM that kind of thing. + * TODO: prefix counts are threads when they should be cores. */ +gchar *processor_frequency_desc(GSList * processors)  { +    gchar *ret = g_strdup(""); +    GSList *tmp, *l;      Processor *p; +    float cur_val = -1; +    gint cur_count = 0; + +    tmp = g_slist_copy(processors); +    tmp = g_slist_sort(tmp, (GCompareFunc)proc_cmp_max_freq); +    for (l = tmp; l; l = l->next) { +        p = (Processor*)l->data; +        if (cur_val == -1) { +            cur_val = p->cpu_mhz; +            cur_count = 1; +        } else { +            if(cur_val != p->cpu_mhz) { +                ret = h_strdup_cprintf("%s%dx %.2f %s", ret, strlen(ret) ? " + " : "", cur_count, cur_val, _("MHz") ); +                cur_val = p->cpu_mhz; +                cur_count = 1; +            } else { +                cur_count++; +            } +        } +    } +    ret = h_strdup_cprintf("%s%dx %0.2f %s", ret, strlen(ret) ? " + " : "", cur_count, cur_val, _("MHz")); +    g_slist_free(tmp); +    return ret; +} + +gchar *get_processor_frequency_desc(void) +{      scan_processors(FALSE); +    return processor_frequency_desc(processors); +} + +gchar *get_processor_max_frequency(void) +{ +    GSList *l; +    Processor *p; +    float max_freq = 0; + +    scan_processors(FALSE); + +    for (l = processors; l; l = l->next) { +        p = (Processor*)l->data; +        if (p->cpu_mhz > max_freq) +            max_freq = p->cpu_mhz; +    } -    p = (Processor *)processors->data; -    if (p->cpu_mhz == 0.0f) { +    if (max_freq == 0.0f) {          return g_strdup(N_("Unknown"));      } else { -        return g_strdup_printf("%.0f", p->cpu_mhz); +        return g_strdup_printf("%.0f %s", max_freq, _("MHz") );      }  } @@ -329,11 +385,12 @@ gchar *get_motherboard(void)  ShellModuleMethod *hi_exported_methods(void)  {      static ShellModuleMethod m[] = { -        {"getProcessorCount", get_processor_count}, +	{"getProcessorCount", get_processor_count},  	{"getProcessorName", get_processor_name},  	{"getProcessorDesc", get_processor_desc},  	{"getProcessorNameAndDesc", get_processor_name_and_desc}, -	{"getProcessorFrequency", get_processor_frequency}, +	{"getProcessorFrequency", get_processor_max_frequency}, +	{"getProcessorFrequencyDesc", get_processor_frequency_desc},  	{"getMemoryTotal", get_memory_total},  	{"getStorageDevices", get_storage_devices},  	{"getPrinters", get_printers}, diff --git a/modules/devices/arm/processor.c b/modules/devices/arm/processor.c index bcfb570e..0448f72a 100644 --- a/modules/devices/arm/processor.c +++ b/modules/devices/arm/processor.c @@ -323,16 +323,24 @@ gchar *processor_describe(GSList * processors) {  gchar *processor_meta(GSList * processors) {      gchar *meta_soc = processor_name(processors);      gchar *meta_cpu_desc = processor_describe(processors); +    gchar *meta_cpu_topo = processor_describe_default(processors); +    gchar *meta_clocks = processor_frequency_desc(processors);      gchar *ret = NULL;      UNKIFNULL(meta_cpu_desc);      ret = g_strdup_printf("[%s]\n"                              "%s=%s\n" +                            "%s=%s\n" +                            "%s=%s\n"                              "%s=%s\n",                              _("SOC/Package"),                              _("Name"), meta_soc, -                            _("Description"), meta_cpu_desc); +                            _("Description"), meta_cpu_desc, +                            _("Topology"), meta_cpu_topo, +                            _("Clocks"), meta_clocks );      g_free(meta_soc);      g_free(meta_cpu_desc); +    g_free(meta_cpu_topo); +    g_free(meta_clocks);      return ret;  } @@ -351,10 +359,10 @@ gchar *processor_get_info(GSList * processors)      for (l = processors; l; l = l->next) {          processor = (Processor *) l->data; -        tmp = g_strdup_printf(_("%s$CPU%d$%s=%.2fMHz\n"), +        tmp = g_strdup_printf(_("%s$CPU%d$%s=%.2f%s\n"),                    tmp, processor->id,                    processor->model_name, -                  processor->cpu_mhz); +                  processor->cpu_mhz, _("MHz"));          hashkey = g_strdup_printf("CPU%d", processor->id);          moreinfo_add_with_prefix("DEV", hashkey, | 
