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() }
 | 
							.js { b.compile_js() }
 | 
				
			||||||
		.native { b.compile_native() }
 | 
							.native { b.compile_native() }
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						util.get_timers().show_remaining()
 | 
				
			||||||
	if pref.is_stats {
 | 
						if pref.is_stats {
 | 
				
			||||||
		compilation_time_micros := 1 + sw.elapsed().microseconds()
 | 
							compilation_time_micros := 1 + sw.elapsed().microseconds()
 | 
				
			||||||
		scompilation_time_ms := util.bold('${f64(compilation_time_micros) / 1000.0:6.3f}')
 | 
							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() {
 | 
					fn (mut s Scanner) init_scanner() {
 | 
				
			||||||
	util.get_timers().measure_pause('PARSE')
 | 
					 | 
				
			||||||
	s.scan_all_tokens_in_buffer(s.comments_mode)
 | 
						s.scan_all_tokens_in_buffer(s.comments_mode)
 | 
				
			||||||
	util.get_timers().measure_resume('PARSE')
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[unsafe]
 | 
					[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) {
 | 
					pub fn (mut s Scanner) scan_all_tokens_in_buffer(mode CommentsMode) {
 | 
				
			||||||
	// s.scan_all_tokens_in_buffer is used mainly by vdoc,
 | 
						util.get_timers().measure_pause('PARSE')
 | 
				
			||||||
	// in order to implement the .toplevel_comments mode.
 | 
					 | 
				
			||||||
	util.timing_start('SCAN')
 | 
						util.timing_start('SCAN')
 | 
				
			||||||
	defer {
 | 
						defer {
 | 
				
			||||||
		util.timing_measure_cumulative('SCAN')
 | 
							util.timing_measure_cumulative('SCAN')
 | 
				
			||||||
 | 
							util.get_timers().measure_resume('PARSE')
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	oldmode := s.comments_mode
 | 
						oldmode := s.comments_mode
 | 
				
			||||||
	s.comments_mode = mode
 | 
						s.comments_mode = mode
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,8 @@ pub struct Timers {
 | 
				
			||||||
pub mut:
 | 
					pub mut:
 | 
				
			||||||
	swatches     map[string]time.StopWatch
 | 
						swatches     map[string]time.StopWatch
 | 
				
			||||||
	should_print bool
 | 
						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 {
 | 
					pub fn new_timers(should_print bool) &Timers {
 | 
				
			||||||
| 
						 | 
					@ -100,6 +102,7 @@ pub fn (mut t Timers) show(label string) {
 | 
				
			||||||
	if t.should_print {
 | 
						if t.should_print {
 | 
				
			||||||
		println(formatted_message)
 | 
							println(formatted_message)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						t.already_shown << label
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn (mut t Timers) show_if_exists(label string) {
 | 
					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
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	t.show(label)
 | 
						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() {
 | 
					pub fn (mut t Timers) dump_all() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue