mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 14:48:47 +00:00
Add extra internal memory analysis
This commit is contained in:
+30
-1
@@ -13,7 +13,7 @@ gb_global Timings global_timings = {0};
|
|||||||
#if defined(LLVM_BACKEND_SUPPORT)
|
#if defined(LLVM_BACKEND_SUPPORT)
|
||||||
#include "llvm-c/Types.h"
|
#include "llvm-c/Types.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "psapi.h"
|
||||||
|
|
||||||
#include "parser.hpp"
|
#include "parser.hpp"
|
||||||
#include "checker.hpp"
|
#include "checker.hpp"
|
||||||
@@ -1614,6 +1614,35 @@ int main(int arg_count, char const **arg_ptr) {
|
|||||||
|
|
||||||
remove_temp_files(gen.output_base);
|
remove_temp_files(gen.output_base);
|
||||||
|
|
||||||
|
if (false) {
|
||||||
|
PROCESS_MEMORY_COUNTERS_EX pmc;
|
||||||
|
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc));
|
||||||
|
SIZE_T virtualMemUsedByMe = pmc.PrivateUsage;
|
||||||
|
gb_printf_err("virtual_memory_used: %tu B\n", virtualMemUsedByMe);
|
||||||
|
|
||||||
|
gb_printf_err("total_allocated_node_memory: %lld B\n", total_allocated_node_memory);
|
||||||
|
gb_printf_err("total_subtype_node_memory_test: %lld B\n", total_subtype_node_memory_test);
|
||||||
|
gb_printf_err("fraction: %.6f\n", (f64)total_subtype_node_memory_test/(f64)total_allocated_node_memory);
|
||||||
|
Parser *p = checker.parser;
|
||||||
|
isize lines = p->total_line_count;
|
||||||
|
isize tokens = p->total_token_count;
|
||||||
|
isize files = 0;
|
||||||
|
isize packages = p->packages.count;
|
||||||
|
isize total_file_size = 0;
|
||||||
|
for_array(i, p->packages) {
|
||||||
|
files += p->packages[i]->files.count;
|
||||||
|
for_array(j, p->packages[i]->files) {
|
||||||
|
AstFile *file = p->packages[i]->files[j];
|
||||||
|
total_file_size += file->tokenizer.end - file->tokenizer.start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gb_printf_err("total_file_size: %lld B\n", total_file_size);
|
||||||
|
gb_printf_err("lines: %lld\n", lines);
|
||||||
|
gb_printf_err("files: %lld\n", files);
|
||||||
|
gb_printf_err("tokens: %lld\n", tokens);
|
||||||
|
gb_printf_err("packages: %lld\n", packages);
|
||||||
|
}
|
||||||
|
|
||||||
if (run_output) {
|
if (run_output) {
|
||||||
#if defined(GB_SYSTEM_WINDOWS)
|
#if defined(GB_SYSTEM_WINDOWS)
|
||||||
return system_exec_command_line_app("odin run", "%.*s.exe %.*s", LIT(gen.output_base), LIT(run_args_string));
|
return system_exec_command_line_app("odin run", "%.*s.exe %.*s", LIT(gen.output_base), LIT(run_args_string));
|
||||||
|
|||||||
@@ -442,9 +442,16 @@ bool ast_node_expect(Ast *node, AstKind kind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gb_global isize volatile total_allocated_node_memory = 0;
|
||||||
|
gb_global isize volatile total_subtype_node_memory_test = 0;
|
||||||
|
|
||||||
// NOTE(bill): And this below is why is I/we need a new language! Discriminated unions are a pain in C/C++
|
// NOTE(bill): And this below is why is I/we need a new language! Discriminated unions are a pain in C/C++
|
||||||
Ast *alloc_ast_node(AstFile *f, AstKind kind) {
|
Ast *alloc_ast_node(AstFile *f, AstKind kind) {
|
||||||
gbAllocator a = ast_allocator();
|
gbAllocator a = ast_allocator();
|
||||||
|
|
||||||
|
_InterlockedExchangeAdd64(&total_allocated_node_memory, gb_size_of(Ast));
|
||||||
|
_InterlockedExchangeAdd64(&total_subtype_node_memory_test, gb_size_of(AstCommonStuff) + ast_variant_sizes[kind]);
|
||||||
|
|
||||||
Ast *node = gb_alloc_item(a, Ast);
|
Ast *node = gb_alloc_item(a, Ast);
|
||||||
node->kind = kind;
|
node->kind = kind;
|
||||||
node->file = f;
|
node->file = f;
|
||||||
|
|||||||
@@ -576,6 +576,16 @@ isize const ast_variant_sizes[] = {
|
|||||||
#undef AST_KIND
|
#undef AST_KIND
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct AstCommonStuff {
|
||||||
|
AstKind kind;
|
||||||
|
u32 state_flags;
|
||||||
|
u32 viral_state_flags;
|
||||||
|
bool been_handled;
|
||||||
|
AstFile * file;
|
||||||
|
Scope * scope;
|
||||||
|
TypeAndValue tav;
|
||||||
|
};
|
||||||
|
|
||||||
struct Ast {
|
struct Ast {
|
||||||
AstKind kind;
|
AstKind kind;
|
||||||
u32 state_flags;
|
u32 state_flags;
|
||||||
|
|||||||
Reference in New Issue
Block a user