v.util: add Timers.show_remaining/0, use it in v.builder.compile/2
							parent
							
								
									59d80e2758
								
							
						
					
					
						commit
						54f6dc70c3
					
				| 
						 | 
				
			
			@ -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}')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue