Expose time stats
This commit is contained in:
@@ -771,7 +771,7 @@ gen_ast(Ast *ast){
|
|||||||
|
|
||||||
CORE_Static String
|
CORE_Static String
|
||||||
compile_to_c_code(){
|
compile_to_c_code(){
|
||||||
pctx->generating_time_begin = os_time();
|
pctx->time.code_generation = os_time();
|
||||||
|
|
||||||
prefixed_string_type = string_fmt(pctx->perm, "%QString", pctx->symbol_prefix);
|
prefixed_string_type = string_fmt(pctx->perm, "%QString", pctx->symbol_prefix);
|
||||||
if(pctx->single_header_library_mode){
|
if(pctx->single_header_library_mode){
|
||||||
@@ -977,6 +977,6 @@ typedef struct String{
|
|||||||
|
|
||||||
|
|
||||||
String string_result = string_flatten(pctx->perm, &pctx->gen);
|
String string_result = string_flatten(pctx->perm, &pctx->gen);
|
||||||
pctx->generating_time_end = os_time();
|
pctx->time.code_generation = os_time() - pctx->time.code_generation;
|
||||||
return string_result;
|
return string_result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
CORE_Static void
|
CORE_Static void
|
||||||
core_init_compiler(Core_Ctx *ctx, Allocator *allocator) {
|
core_init_compiler(Core_Ctx *ctx, Allocator *allocator) {
|
||||||
ctx->init_ctx_time_begin = os_time();
|
ctx->time.init_context = os_time();
|
||||||
pctx = ctx;
|
pctx = ctx;
|
||||||
|
|
||||||
ctx->emit_type_info = true;
|
ctx->emit_type_info = true;
|
||||||
@@ -155,7 +155,7 @@ pctx->op_info_table[19] = {pctx->intern("!"_s), "NOT"_s, TK_Not, 0, 1};
|
|||||||
|
|
||||||
String main_module = string_fmt(ctx->perm, "%Q/modules", ctx->exe_folder);
|
String main_module = string_fmt(ctx->perm, "%Q/modules", ctx->exe_folder);
|
||||||
add(ctx->perm, &ctx->module_folders, main_module);
|
add(ctx->perm, &ctx->module_folders, main_module);
|
||||||
ctx->init_ctx_time_end = os_time();
|
ctx->time.init_context = os_time() - ctx->time.init_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
CORE_Static void
|
CORE_Static void
|
||||||
@@ -177,7 +177,7 @@ insert_builtin_type_into_scope(Ast_Scope *p, String name, Ast_Type *type) {
|
|||||||
|
|
||||||
CORE_Static void
|
CORE_Static void
|
||||||
parse_all_modules() {
|
parse_all_modules() {
|
||||||
pctx->parsing_time_begin = os_time();
|
pctx->time.parsing = os_time();
|
||||||
|
|
||||||
For_Named(pctx->modules, module) {
|
For_Named(pctx->modules, module) {
|
||||||
if (module->state != MODULE_REGISTERED)
|
if (module->state != MODULE_REGISTERED)
|
||||||
@@ -194,7 +194,7 @@ parse_all_modules() {
|
|||||||
|
|
||||||
module->state = MODULE_PARSED;
|
module->state = MODULE_PARSED;
|
||||||
}
|
}
|
||||||
pctx->parsing_time_end = os_time();
|
pctx->time.parsing = os_time() - pctx->time.parsing;
|
||||||
}
|
}
|
||||||
|
|
||||||
CORE_Static Ast_Module *
|
CORE_Static Ast_Module *
|
||||||
@@ -260,7 +260,7 @@ CORE_Static void
|
|||||||
resolve_everything_in_module(Ast_Module *module) {
|
resolve_everything_in_module(Ast_Module *module) {
|
||||||
if (module->state == MODULE_RESOLVED)
|
if (module->state == MODULE_RESOLVED)
|
||||||
return;
|
return;
|
||||||
pctx->resolving_time_begin = os_time();
|
pctx->time.typechecking = os_time();
|
||||||
For_Named(module->all_loaded_files, file) {
|
For_Named(module->all_loaded_files, file) {
|
||||||
For_Named(file->decls, decl) {
|
For_Named(file->decls, decl) {
|
||||||
resolve_name(file, decl->pos, decl->name);
|
resolve_name(file, decl->pos, decl->name);
|
||||||
@@ -271,14 +271,15 @@ resolve_everything_in_module(Ast_Module *module) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
module->state = MODULE_RESOLVED;
|
module->state = MODULE_RESOLVED;
|
||||||
pctx->resolving_time_end = os_time();
|
pctx->time.typechecking = os_time() - pctx->time.typechecking;
|
||||||
}
|
}
|
||||||
|
|
||||||
CORE_Static String
|
CORE_Static String
|
||||||
compile_file_to_string(Allocator *allocator, String filename) {
|
compile_file_to_string(Allocator *allocator, String filename) {
|
||||||
F64 total_time = os_time();
|
F64 total_time = os_time();
|
||||||
core_bootstrap_compiler(allocator);
|
core_bootstrap_compiler(allocator);
|
||||||
pctx->total_time = total_time;
|
pctx->time.total = total_time;
|
||||||
|
pctx->time.start = total_time;
|
||||||
{
|
{
|
||||||
Ast_Module *module = add_module(0, pctx->intern("Language.core"_s));
|
Ast_Module *module = add_module(0, pctx->intern("Language.core"_s));
|
||||||
{
|
{
|
||||||
@@ -343,5 +344,7 @@ compile_file_to_string(Allocator *allocator, String filename) {
|
|||||||
|
|
||||||
pctx->stage_arena->len = 0;
|
pctx->stage_arena->len = 0;
|
||||||
String result = compile_to_c_code();
|
String result = compile_to_c_code();
|
||||||
|
|
||||||
|
pctx->time.total = os_time() - pctx->time.total;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,6 @@
|
|||||||
@! Bring the Table<>
|
@! Bring the Table<>
|
||||||
@! Look into List, check if that's neccessary
|
@! Look into List, check if that's neccessary
|
||||||
|
|
||||||
@! Compute time statistics inside context and expose them properly
|
|
||||||
|
|
||||||
Probably want to implement a Red Black Tree then
|
Probably want to implement a Red Black Tree then
|
||||||
probably I wouldn't need any sort of heap based
|
probably I wouldn't need any sort of heap based
|
||||||
data structure.
|
data structure.
|
||||||
@@ -79,15 +77,15 @@ struct Core_Ctx{
|
|||||||
String working_folder;
|
String working_folder;
|
||||||
List<Token *> files_to_link;
|
List<Token *> files_to_link;
|
||||||
|
|
||||||
F64 generating_time_begin;
|
struct {
|
||||||
F64 generating_time_end;
|
F64 typechecking;
|
||||||
F64 resolving_time_begin;
|
F64 code_generation;
|
||||||
F64 resolving_time_end;
|
F64 total;
|
||||||
F64 total_time;
|
F64 init_context;
|
||||||
F64 init_ctx_time_begin;
|
F64 parsing;
|
||||||
F64 init_ctx_time_end;
|
|
||||||
F64 parsing_time_begin;
|
F64 start;
|
||||||
F64 parsing_time_end;
|
} time;
|
||||||
|
|
||||||
bool color_codes_enabled;
|
bool color_codes_enabled;
|
||||||
bool debugger_break_on_compiler_error;
|
bool debugger_break_on_compiler_error;
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ static void compile_file(Allocator *allocator, String filename, U32 compile_flag
|
|||||||
|
|
||||||
B32 r = os_write_file("program.c"_s, result);
|
B32 r = os_write_file("program.c"_s, result);
|
||||||
assert(r);
|
assert(r);
|
||||||
F64 total_compiler_time = os_time() - pctx->total_time;
|
F64 total_compiler_time = os_time() - pctx->time.start;
|
||||||
printf("%f - ", total_compiler_time);
|
printf("%f - ", total_compiler_time);
|
||||||
|
|
||||||
Scratch_Arena *scratch = pctx->scratch;
|
Scratch_Arena *scratch = pctx->scratch;
|
||||||
@@ -291,11 +291,12 @@ static void compile_file(Allocator *allocator, String filename, U32 compile_flag
|
|||||||
F64 end = os_time();
|
F64 end = os_time();
|
||||||
|
|
||||||
if (is_flag_set(compile_flags, COMPILE_PRINT_STATS)) {
|
if (is_flag_set(compile_flags, COMPILE_PRINT_STATS)) {
|
||||||
printf("total = %f\n", os_time() - pctx->total_time);
|
printf("total = %f\n", os_time() - pctx->time.start);
|
||||||
printf("clang = %f\n", end - begin);
|
printf("core_total = %f\n", pctx->time.total);
|
||||||
printf("parsing = %f\n", pctx->parsing_time_end - pctx->parsing_time_begin);
|
printf("clang = %f\n", end - begin);
|
||||||
printf("resolving = %f\n", pctx->resolving_time_end - pctx->resolving_time_begin);
|
printf("parsing = %f\n", pctx->time.parsing);
|
||||||
printf("generatin = %f\n", pctx->generating_time_end - pctx->generating_time_begin);
|
printf("typecheck = %f\n", pctx->time.typechecking);
|
||||||
|
printf("generatin = %f\n", pctx->time.code_generation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_flag_set(compile_flags, COMPILE_PRINT_ALLOCATOR_STATS_BEFORE_DESTROY)) {
|
if (is_flag_set(compile_flags, COMPILE_PRINT_ALLOCATOR_STATS_BEFORE_DESTROY)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user