mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-23 07:57:52 +00:00
Simplify TIME_SECTION code
This commit is contained in:
@@ -853,8 +853,6 @@ void init_universal(void) {
|
||||
|
||||
|
||||
void init_checker_info(CheckerInfo *i) {
|
||||
#define TIME_SECTION(str) do { debugf("[Subsection] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
|
||||
|
||||
gbAllocator a = heap_allocator();
|
||||
|
||||
TIME_SECTION("checker info: general");
|
||||
@@ -903,9 +901,6 @@ void init_checker_info(CheckerInfo *i) {
|
||||
mutex_init(&i->foreign_mutex);
|
||||
|
||||
semaphore_init(&i->collect_semaphore);
|
||||
|
||||
|
||||
#undef TIME_SECTION
|
||||
}
|
||||
|
||||
void destroy_checker_info(CheckerInfo *i) {
|
||||
@@ -982,7 +977,6 @@ void reset_checker_context(CheckerContext *ctx, AstFile *file, UntypedExprInfoMa
|
||||
|
||||
|
||||
void init_checker(Checker *c) {
|
||||
#define TIME_SECTION(str) do { debugf("[Subsection] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
|
||||
gbAllocator a = heap_allocator();
|
||||
|
||||
TIME_SECTION("init checker info");
|
||||
@@ -1000,8 +994,6 @@ void init_checker(Checker *c) {
|
||||
mpmc_init(&c->global_untyped_queue, a, 1<<20);
|
||||
|
||||
c->builtin_ctx = make_checker_context(c);
|
||||
|
||||
#undef TIME_SECTION
|
||||
}
|
||||
|
||||
void destroy_checker(Checker *c) {
|
||||
@@ -2183,8 +2175,6 @@ void add_entity_dependency_from_procedure_parameters(Map<EntityGraphNode *> *M,
|
||||
}
|
||||
|
||||
Array<EntityGraphNode *> generate_entity_dependency_graph(CheckerInfo *info, gbAllocator allocator) {
|
||||
#define TIME_SECTION(str) do { debugf("[Section] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
|
||||
|
||||
Map<EntityGraphNode *> M = {}; // Key: Entity *
|
||||
map_init(&M, allocator, info->entities.count);
|
||||
defer (map_destroy(&M));
|
||||
@@ -2303,8 +2293,6 @@ Array<EntityGraphNode *> generate_entity_dependency_graph(CheckerInfo *info, gbA
|
||||
// gb_printf_err(">>>max pred: %f succ: %f\n", pred_max, succ_max);
|
||||
|
||||
return G;
|
||||
|
||||
#undef TIME_SECTION
|
||||
}
|
||||
|
||||
|
||||
@@ -4313,8 +4301,6 @@ void check_export_entities(Checker *c) {
|
||||
}
|
||||
|
||||
void check_import_entities(Checker *c) {
|
||||
#define TIME_SECTION(str) do { debugf("[Section] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
|
||||
|
||||
Array<ImportGraphNode *> dep_graph = generate_import_dependency_graph(c);
|
||||
defer ({
|
||||
for_array(i, dep_graph) {
|
||||
@@ -4444,8 +4430,6 @@ void check_import_entities(Checker *c) {
|
||||
add_untyped_expressions(ctx.info, &untyped);
|
||||
}
|
||||
}
|
||||
|
||||
#undef TIME_SECTION
|
||||
}
|
||||
|
||||
|
||||
@@ -4538,8 +4522,6 @@ Array<Entity *> find_entity_path(Entity *start, Entity *end, Map<Entity *> *visi
|
||||
|
||||
|
||||
void calculate_global_init_order(Checker *c) {
|
||||
#define TIME_SECTION(str) do { debugf("[Section] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
|
||||
|
||||
CheckerInfo *info = &c->info;
|
||||
|
||||
TIME_SECTION("calculate_global_init_order: generate entity dependency graph");
|
||||
@@ -4611,8 +4593,6 @@ void calculate_global_init_order(Checker *c) {
|
||||
}
|
||||
gb_printf("\n");
|
||||
}
|
||||
|
||||
#undef TIME_SECTION
|
||||
}
|
||||
|
||||
|
||||
@@ -5152,8 +5132,6 @@ void check_sort_init_procedures(Checker *c) {
|
||||
|
||||
|
||||
void check_parsed_files(Checker *c) {
|
||||
#define TIME_SECTION(str) do { debugf("[Section] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
|
||||
|
||||
TIME_SECTION("map full filepaths to scope");
|
||||
add_type_info_type(&c->builtin_ctx, t_invalid);
|
||||
|
||||
@@ -5322,6 +5300,4 @@ void check_parsed_files(Checker *c) {
|
||||
check_sort_init_procedures(c);
|
||||
|
||||
TIME_SECTION("type check finish");
|
||||
|
||||
#undef TIME_SECTION
|
||||
}
|
||||
|
||||
@@ -1120,9 +1120,6 @@ void lb_generate_procedure(lbModule *m, lbProcedure *p) {
|
||||
|
||||
|
||||
void lb_generate_code(lbGenerator *gen) {
|
||||
#define TIME_SECTION(str) do { if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
|
||||
#define TIME_SECTION_WITH_LEN(str, len) do { if (build_context.show_more_timings) timings_start_section(&global_timings, make_string((u8 *)str, len)); } while (0)
|
||||
|
||||
TIME_SECTION("LLVM Initializtion");
|
||||
|
||||
isize thread_count = gb_max(build_context.thread_count, 1);
|
||||
@@ -1745,8 +1742,4 @@ void lb_generate_code(lbGenerator *gen) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#undef TIME_SECTION
|
||||
}
|
||||
|
||||
+8
-7
@@ -1627,6 +1627,8 @@ void show_timings(Checker *c, Timings *t) {
|
||||
|
||||
void remove_temp_files(lbGenerator *gen) {
|
||||
if (build_context.keep_temp_files) return;
|
||||
|
||||
TIME_SECTION("remove keep temp files");
|
||||
|
||||
for_array(i, gen->output_temp_paths) {
|
||||
String path = gen->output_temp_paths[i];
|
||||
@@ -2223,7 +2225,6 @@ int strip_semicolons(Parser *parser) {
|
||||
|
||||
|
||||
int main(int arg_count, char const **arg_ptr) {
|
||||
#define TIME_SECTION(str) do { debugf("[Section] %s\n", str); timings_start_section(&global_timings, str_lit(str)); } while (0)
|
||||
if (arg_count < 2) {
|
||||
usage(make_string_c(arg_ptr[0]));
|
||||
return 1;
|
||||
@@ -2232,7 +2233,7 @@ int main(int arg_count, char const **arg_ptr) {
|
||||
timings_init(&global_timings, str_lit("Total Time"), 2048);
|
||||
defer (timings_destroy(&global_timings));
|
||||
|
||||
TIME_SECTION("initialization");
|
||||
MAIN_TIME_SECTION("initialization");
|
||||
|
||||
virtual_memory_init();
|
||||
mutex_init(&fullpath_mutex);
|
||||
@@ -2410,7 +2411,7 @@ int main(int arg_count, char const **arg_ptr) {
|
||||
Parser *parser = gb_alloc_item(permanent_allocator(), Parser);
|
||||
Checker *checker = gb_alloc_item(permanent_allocator(), Checker);
|
||||
|
||||
TIME_SECTION("parse files");
|
||||
MAIN_TIME_SECTION("parse files");
|
||||
|
||||
if (!init_parser(parser)) {
|
||||
return 1;
|
||||
@@ -2425,7 +2426,7 @@ int main(int arg_count, char const **arg_ptr) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
TIME_SECTION("type check");
|
||||
MAIN_TIME_SECTION("type check");
|
||||
|
||||
checker->parser = parser;
|
||||
init_checker(checker);
|
||||
@@ -2468,7 +2469,7 @@ int main(int arg_count, char const **arg_ptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
TIME_SECTION("LLVM API Code Gen");
|
||||
MAIN_TIME_SECTION("LLVM API Code Gen");
|
||||
lbGenerator *gen = gb_alloc_item(permanent_allocator(), lbGenerator);
|
||||
if (!lb_init_generator(gen, checker)) {
|
||||
return 1;
|
||||
@@ -2488,12 +2489,12 @@ int main(int arg_count, char const **arg_ptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
remove_temp_files(gen);
|
||||
|
||||
if (build_context.show_timings) {
|
||||
show_timings(checker, &global_timings);
|
||||
}
|
||||
|
||||
remove_temp_files(gen);
|
||||
|
||||
if (run_output) {
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
return system_exec_command_line_app("odin run", "%.*s.exe %.*s", LIT(gen->output_base), LIT(run_args_string));
|
||||
|
||||
@@ -145,6 +145,11 @@ f64 time_stamp_as_us(TimeStamp const &ts, u64 freq) {
|
||||
return 1000000.0*time_stamp_as_s(ts, freq);
|
||||
}
|
||||
|
||||
#define MAIN_TIME_SECTION(str) do { debugf("[Section] %s\n", str); timings_start_section(&global_timings, str_lit(str)); } while (0)
|
||||
#define TIME_SECTION(str) do { debugf("[Section] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, str_lit(str)); } while (0)
|
||||
#define TIME_SECTION_WITH_LEN(str, len) do { debugf("[Section] %s\n", str); if (build_context.show_more_timings) timings_start_section(&global_timings, make_string((u8 *)str, len)); } while (0)
|
||||
|
||||
|
||||
enum TimingUnit {
|
||||
TimingUnit_Second,
|
||||
TimingUnit_Millisecond,
|
||||
|
||||
Reference in New Issue
Block a user