mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-26 00:10:38 +01:00
[v0.98][Refactoring] Unify the use of get_str_peak_performance
This commit is contained in:
@@ -151,6 +151,28 @@ char* get_str_freq(struct frequency* freq) {
|
||||
return string;
|
||||
}
|
||||
|
||||
char* get_str_peak_performance(double flops, bool valid_flops) {
|
||||
char* str;
|
||||
|
||||
if(!valid_flops) {
|
||||
str = emalloc(sizeof(char) * (strlen(STRING_UNKNOWN) + 1));
|
||||
strncpy(str, STRING_UNKNOWN, strlen(STRING_UNKNOWN) + 1);
|
||||
}
|
||||
|
||||
// 7 for digits (e.g, XXXX.XX), 7 for XFLOP/s
|
||||
uint32_t max_size = 7+1+7+1;
|
||||
str = ecalloc(max_size, sizeof(char));
|
||||
|
||||
if(flops >= (double)1000000000000.0)
|
||||
snprintf(str, max_size, "%.2f TFLOP/s", flops/1000000000000);
|
||||
else if(flops >= 1000000000.0)
|
||||
snprintf(str, max_size, "%.2f GFLOP/s", flops/1000000000);
|
||||
else
|
||||
snprintf(str, max_size, "%.2f MFLOP/s", flops/1000000);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
void init_topology_struct(struct topology* topo, struct cache* cach) {
|
||||
topo->total_cores = 0;
|
||||
topo->cach = cach;
|
||||
|
||||
Reference in New Issue
Block a user