Add extra guards for window-only performance checking

This commit is contained in:
gingerBill
2020-04-07 11:47:28 +01:00
parent 7ff690500a
commit 29a3cb25d3
3 changed files with 17 additions and 11 deletions
+5 -1
View File
@@ -8,10 +8,10 @@
#endif
#if defined(GB_SYSTEM_WINDOWS)
#define NOMINMAX 1
#include <windows.h>
#undef NOMINMAX
#include <psapi.h>
#endif
#define GB_WINDOWS_H_INCLUDED
@@ -21,6 +21,10 @@
#include <wchar.h>
#include <stdio.h>
#if defined(GB_COMPILER_MSVC)
#include <psapi.h>
#endif
#include <math.h>
template <typename U, typename V>
+8 -6
View File
@@ -1613,15 +1613,16 @@ int main(int arg_count, char const **arg_ptr) {
remove_temp_files(gen.output_base);
#if defined(GB_COMPILER_MSVC)
if (false) {
PROCESS_MEMORY_COUNTERS_EX pmc;
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);
SIZE_T virtual_mem_used_by_me = pmc.PrivateUsage;
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_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);
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.value);
gb_printf_err("fraction: %.6f\n", (f64)total_subtype_node_memory_test.value/(f64)total_allocated_node_memory.value);
Parser *p = checker.parser;
isize lines = p->total_line_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("packages: %lld\n", packages);
}
#endif
if (run_output) {
#if defined(GB_SYSTEM_WINDOWS)
+4 -4
View File
@@ -442,15 +442,15 @@ 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;
gb_global gbAtomic64 total_allocated_node_memory = {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++
Ast *alloc_ast_node(AstFile *f, AstKind kind) {
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]);
gb_atomic64_fetch_add(&total_allocated_node_memory, cast(i64)(gb_size_of(Ast)));
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);
node->kind = kind;