diff --git a/vlib/v/builder/builder.v b/vlib/v/builder/builder.v index 1c7445cfb4..1d73dbf712 100644 --- a/vlib/v/builder/builder.v +++ b/vlib/v/builder/builder.v @@ -26,7 +26,7 @@ pub mut: parsed_files []ast.File cached_msvc MsvcResult table &table.Table - timers &util.Timers + timers &util.Timers = util.new_timers(false) } pub fn new_builder(pref &pref.Preferences) Builder { diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index ffbe8cd58d..ca111bb3cb 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -66,7 +66,7 @@ mut: vweb_gen_types []table.Type // vweb route checks prevent_sum_type_unwrapping_once bool // needed for assign new values to sum type, stopping unwrapping then loop_label string // set when inside a labelled for loop - timers &util.Timers + timers &util.Timers = util.new_timers(false) } pub fn new_checker(table &table.Table, pref &pref.Preferences) Checker { diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 9bd7a9bc2d..9808ff96a4 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -129,7 +129,7 @@ mut: aggregate_type_idx int returned_var_name string // to detect that a var doesn't need to be freed since it's being returned branch_parent_pos int // used in BranchStmt (continue/break) for autofree stop position - timers &util.Timers + timers &util.Timers = util.new_timers(false) } const ( @@ -182,12 +182,13 @@ pub fn cgen(files []ast.File, table &table.Table, pref &pref.Preferences) string module_built: module_built timers: util.new_timers(timers_should_print) } + g.timers.start('cgen init') for mod in g.table.modules { g.inits[mod] = strings.new_builder(100) g.cleanups[mod] = strings.new_builder(100) } - g.timers.start('cgen common') g.init() + g.timers.show('cgen init') // mut tests_inited := false mut autofree_used := false @@ -220,6 +221,7 @@ pub fn cgen(files []ast.File, table &table.Table, pref &pref.Preferences) string g.stmts(file.stmts) g.timers.show('cgen_file $file.path') } + g.timers.start('cgen common') if autofree_used { g.autofree = true // so that void _vcleanup is generated } diff --git a/vlib/v/util/timers.v b/vlib/v/util/timers.v index f637b799e8..3b56d58332 100644 --- a/vlib/v/util/timers.v +++ b/vlib/v/util/timers.v @@ -37,8 +37,8 @@ pub fn (mut t Timers) measure(name string) i64 { pub fn (mut t Timers) message(name string) string { ms := f64(t.measure(name)) / 1000.0 - value := bold('${ms:.3f}') - formatted_message := '$name: $value ms' + value := bold('${ms:-8.3f}') + formatted_message := '$value ms $name' return formatted_message }