mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-31 01:56:28 +01:00
New caching mechanism for CPU
This commit is contained in:
+33
-32
@@ -8,10 +8,7 @@
|
||||
|
||||
void ffPrintCPU(FFinstance* instance)
|
||||
{
|
||||
if(ffPrintFromCache(instance, FF_CPU_MODULE_NAME, &instance->config.cpu, FF_CPU_NUM_FORMAT_ARGS))
|
||||
return;
|
||||
|
||||
const FFCPUResult* cpu = ffDetectCPU();
|
||||
const FFCPUResult* cpu = ffDetectCPU(instance);
|
||||
|
||||
if(cpu->vendor.length == 0 && cpu->name.length == 0 && cpu->coresOnline <= 1)
|
||||
{
|
||||
@@ -19,35 +16,39 @@ void ffPrintCPU(FFinstance* instance)
|
||||
return;
|
||||
}
|
||||
|
||||
FFstrbuf output;
|
||||
ffStrbufInitA(&output, 128);
|
||||
|
||||
if(cpu->name.length > 0)
|
||||
ffStrbufAppend(&output, &cpu->name);
|
||||
else if(cpu->vendor.length > 0)
|
||||
if(instance->config.cpu.outputFormat.length == 0)
|
||||
{
|
||||
ffStrbufAppend(&output, &cpu->vendor);
|
||||
ffStrbufAppendS(&output, " CPU");
|
||||
ffPrintLogoAndKey(instance, FF_CPU_MODULE_NAME, 0, &instance->config.cpu.key);
|
||||
|
||||
if(cpu->name.length > 0)
|
||||
ffStrbufWriteTo(&cpu->name, stdout);
|
||||
else if(cpu->vendor.length > 0)
|
||||
{
|
||||
ffStrbufWriteTo(&cpu->vendor, stdout);
|
||||
fputs(" CPU", stdout);
|
||||
}
|
||||
else
|
||||
fputs("CPU", stdout);
|
||||
|
||||
if(cpu->coresOnline > 1)
|
||||
printf(" (%u)", cpu->coresOnline);
|
||||
|
||||
if(cpu->frequencyMax > 0.0)
|
||||
printf(" @ %.9g GHz", cpu->frequencyMax);
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
ffStrbufAppendS(&output, "CPU");
|
||||
|
||||
if(cpu->coresOnline > 1)
|
||||
ffStrbufAppendF(&output, " (%u)", cpu->coresOnline);
|
||||
|
||||
if(cpu->frequencyMax > 0.0)
|
||||
ffStrbufAppendF(&output, " @ %.9gGHz", cpu->frequencyMax);
|
||||
|
||||
ffPrintAndWriteToCache(instance, FF_CPU_MODULE_NAME, &instance->config.cpu, &output, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu->vendor},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresPhysical},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresLogical},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresOnline},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMin},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMax},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->temperature}
|
||||
});
|
||||
|
||||
ffStrbufDestroy(&output);
|
||||
{
|
||||
ffPrintFormat(instance, FF_CPU_MODULE_NAME, 0, &instance->config.cpu, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu->name},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu->vendor},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresPhysical},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresLogical},
|
||||
{FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresOnline},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMin},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMax},
|
||||
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->temperature}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user