diff --git a/vlib/v/builder/compile.v b/vlib/v/builder/compile.v index 7116efac68..3b5a2beb20 100644 --- a/vlib/v/builder/compile.v +++ b/vlib/v/builder/compile.v @@ -43,6 +43,7 @@ pub fn compile(command string, pref &pref.Preferences) { .js { b.compile_js() } .native { b.compile_native() } } + util.get_timers().show_remaining() if pref.is_stats { compilation_time_micros := 1 + sw.elapsed().microseconds() scompilation_time_ms := util.bold('${f64(compilation_time_micros) / 1000.0:6.3f}') diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 56d09c03d3..ec5035396a 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -142,9 +142,7 @@ pub fn new_scanner(text string, comments_mode CommentsMode, pref &pref.Preferenc } fn (mut s Scanner) init_scanner() { - util.get_timers().measure_pause('PARSE') s.scan_all_tokens_in_buffer(s.comments_mode) - util.get_timers().measure_resume('PARSE') } [unsafe] @@ -539,11 +537,11 @@ fn (mut s Scanner) end_of_file() token.Token { } pub fn (mut s Scanner) scan_all_tokens_in_buffer(mode CommentsMode) { - // s.scan_all_tokens_in_buffer is used mainly by vdoc, - // in order to implement the .toplevel_comments mode. + util.get_timers().measure_pause('PARSE') util.timing_start('SCAN') defer { util.timing_measure_cumulative('SCAN') + util.get_timers().measure_resume('PARSE') } oldmode := s.comments_mode s.comments_mode = mode diff --git a/vlib/v/util/timers.v b/vlib/v/util/timers.v index 60ae92b60d..7a0b9662a4 100644 --- a/vlib/v/util/timers.v +++ b/vlib/v/util/timers.v @@ -10,6 +10,8 @@ pub struct Timers { pub mut: swatches map[string]time.StopWatch should_print bool + // already_shown records for which of the swatches .show() or .show_if_exists() had been called already + already_shown []string } pub fn new_timers(should_print bool) &Timers { @@ -100,6 +102,7 @@ pub fn (mut t Timers) show(label string) { if t.should_print { println(formatted_message) } + t.already_shown << label } pub fn (mut t Timers) show_if_exists(label string) { @@ -107,6 +110,16 @@ pub fn (mut t Timers) show_if_exists(label string) { return } t.show(label) + t.already_shown << label +} + +pub fn (mut t Timers) show_remaining() { + for k, _ in t.swatches { + if k in t.already_shown { + continue + } + t.show(k) + } } pub fn (mut t Timers) dump_all() {