v.util: simplify the sorting of v's timing output

pull/7416/head
Delyan Angelov 2020-12-19 12:49:28 +02:00
parent a1c81aa49d
commit 2f1cc2bd08
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
4 changed files with 8 additions and 6 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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
}

View File

@ -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
}