Correct format strings

This commit is contained in:
gingerBill
2025-09-29 16:51:38 +01:00
parent 9e8be055c1
commit 34d040cef1
2 changed files with 46 additions and 9 deletions

View File

@@ -186,9 +186,32 @@ gb_internal bool lb_init_generator(lbGenerator *gen, Checker *c) {
lb_init_module(pm, do_threading);
}
if (pkg->kind == Package_Runtime) {
// allow this to be per file
} else if (!module_per_file) {
bool allow_for_per_file = pkg->kind == Package_Runtime || module_per_file;
#if 0
if (!allow_for_per_file) {
if (pkg->files.count >= 20) {
isize proc_count = 0;
for (Entity *e : gen->info->entities) {
if (e->kind != Entity_Procedure) {
continue;
}
if (e->Procedure.is_foreign) {
continue;
}
if (e->pkg == pkg) {
proc_count += 1;
}
}
if (proc_count >= 300) {
allow_for_per_file = true;
}
}
}
#endif
if (!allow_for_per_file) {
continue;
}
// NOTE(bill): Probably per file is not a good idea, so leave this for later

View File

@@ -2897,7 +2897,7 @@ gb_internal void lb_do_para_poly_diagnostics(lbGenerator *gen) {
f64 average = cast(f64)code_size / cast(f64)gb_max(count, 1);
gb_printf("%23td | %19d | %25.2f | %.*s\n", code_size, count, average, LIT(name));
gb_printf("%23td | %19td | %25.2f | %.*s\n", code_size, count, average, LIT(name));
if (max_count-- <= 0) {
break;
}
@@ -2930,7 +2930,7 @@ gb_internal void lb_do_para_poly_diagnostics(lbGenerator *gen) {
f64 average = cast(f64)code_size / cast(f64)gb_max(count, 1);
gb_printf("%19d | %23td | %25.2f | %.*s\n", count, code_size, average, LIT(name));
gb_printf("%19td | %23td | %25.2f | %.*s\n", count, code_size, average, LIT(name));
if (max_count-- <= 0) {
break;
}
@@ -2989,8 +2989,8 @@ gb_internal void lb_do_module_diagnostics(lbGenerator *gen) {
array_init(&modules, heap_allocator());
defer (array_free(&modules));
for (auto &entry : gen->modules) {
lbModule *m = entry.value;
for (auto &em : gen->modules) {
lbModule *m = em.value;
{
lbDiagModuleEntry entry = {};
@@ -3040,14 +3040,28 @@ gb_internal void lb_do_module_diagnostics(lbGenerator *gen) {
});
gb_printf("Module Diagnostics\n\n");
gb_printf("Total Instructions | Global Internals | Global Externals | Proc Internals | Proc Externals | Module Name\n");
gb_printf("Total Instructions | Global Internals | Global Externals | Proc Internals | Proc Externals | Files | Instructions/File | Instructions/Proc | Module Name\n");
gb_printf("-------------------+------------------+------------------+----------------+----------------+-------+-------------------+-------------------+------------\n");
for (auto &entry : modules) {
gb_printf("%18td | %16td | %16td | %14td | %14d | %s \n",
isize file_count = 1;
if (entry.m->file != nullptr) {
file_count = 1;
} else if (entry.m->pkg) {
file_count = entry.m->pkg->files.count;
}
f64 instructions_per_file = cast(f64)entry.total_instruction_count / gb_max(1.0, cast(f64)file_count);
f64 instructions_per_proc = cast(f64)entry.total_instruction_count / gb_max(1.0, cast(f64)entry.proc_internal_count);
gb_printf("%18td | %16td | %16td | %14td | %14td | %5td | %17.1f | %17.1f | %s \n",
entry.total_instruction_count,
entry.global_internal_count,
entry.global_external_count,
entry.proc_internal_count,
entry.proc_external_count,
file_count,
instructions_per_file,
instructions_per_proc,
entry.m->module_name);
}