mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Add extra guards for window-only performance checking
This commit is contained in:
+5
-1
@@ -8,10 +8,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GB_SYSTEM_WINDOWS)
|
#if defined(GB_SYSTEM_WINDOWS)
|
||||||
|
|
||||||
#define NOMINMAX 1
|
#define NOMINMAX 1
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#undef NOMINMAX
|
#undef NOMINMAX
|
||||||
#include <psapi.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GB_WINDOWS_H_INCLUDED
|
#define GB_WINDOWS_H_INCLUDED
|
||||||
@@ -21,6 +21,10 @@
|
|||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#if defined(GB_COMPILER_MSVC)
|
||||||
|
#include <psapi.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
template <typename U, typename V>
|
template <typename U, typename V>
|
||||||
|
|||||||
+8
-6
@@ -1613,15 +1613,16 @@ int main(int arg_count, char const **arg_ptr) {
|
|||||||
|
|
||||||
remove_temp_files(gen.output_base);
|
remove_temp_files(gen.output_base);
|
||||||
|
|
||||||
|
#if defined(GB_COMPILER_MSVC)
|
||||||
if (false) {
|
if (false) {
|
||||||
PROCESS_MEMORY_COUNTERS_EX pmc;
|
PROCESS_MEMORY_COUNTERS_EX pmc = {};
|
||||||
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc));
|
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc));
|
||||||
SIZE_T virtualMemUsedByMe = pmc.PrivateUsage;
|
SIZE_T virtual_mem_used_by_me = pmc.PrivateUsage;
|
||||||
gb_printf_err("virtual_memory_used: %tu B\n", virtualMemUsedByMe);
|
gb_printf_err("virtual_memory_used: %tu B\n", virtual_mem_used_by_me);
|
||||||
|
|
||||||
gb_printf_err("total_allocated_node_memory: %lld B\n", total_allocated_node_memory);
|
gb_printf_err("total_allocated_node_memory: %lld B\n", total_allocated_node_memory.value);
|
||||||
gb_printf_err("total_subtype_node_memory_test: %lld B\n", total_subtype_node_memory_test);
|
gb_printf_err("total_subtype_node_memory_test: %lld B\n", total_subtype_node_memory_test.value);
|
||||||
gb_printf_err("fraction: %.6f\n", (f64)total_subtype_node_memory_test/(f64)total_allocated_node_memory);
|
gb_printf_err("fraction: %.6f\n", (f64)total_subtype_node_memory_test.value/(f64)total_allocated_node_memory.value);
|
||||||
Parser *p = checker.parser;
|
Parser *p = checker.parser;
|
||||||
isize lines = p->total_line_count;
|
isize lines = p->total_line_count;
|
||||||
isize tokens = p->total_token_count;
|
isize tokens = p->total_token_count;
|
||||||
@@ -1641,6 +1642,7 @@ int main(int arg_count, char const **arg_ptr) {
|
|||||||
gb_printf_err("tokens: %lld\n", tokens);
|
gb_printf_err("tokens: %lld\n", tokens);
|
||||||
gb_printf_err("packages: %lld\n", packages);
|
gb_printf_err("packages: %lld\n", packages);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (run_output) {
|
if (run_output) {
|
||||||
#if defined(GB_SYSTEM_WINDOWS)
|
#if defined(GB_SYSTEM_WINDOWS)
|
||||||
|
|||||||
+4
-4
@@ -442,15 +442,15 @@ bool ast_node_expect(Ast *node, AstKind kind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gb_global isize volatile total_allocated_node_memory = 0;
|
gb_global gbAtomic64 total_allocated_node_memory = {0};
|
||||||
gb_global isize volatile total_subtype_node_memory_test = 0;
|
gb_global gbAtomic64 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));
|
gb_atomic64_fetch_add(&total_allocated_node_memory, cast(i64)(gb_size_of(Ast)));
|
||||||
_InterlockedExchangeAdd64(&total_subtype_node_memory_test, gb_size_of(AstCommonStuff) + ast_variant_sizes[kind]);
|
gb_atomic64_fetch_add(&total_subtype_node_memory_test, cast(i64)(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;
|
||||||
|
|||||||
Reference in New Issue
Block a user