mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builder: show timing info in bold; also add a checker summary:
line with -stats
This commit is contained in:
parent
3c1427a4e8
commit
c1e14b451e
@ -237,7 +237,14 @@ pub fn (b &Builder) find_module_path(mod, fpath string) ?string {
|
||||
return error('module "$mod" not found in:\n$smodule_lookup_paths')
|
||||
}
|
||||
|
||||
fn (b &Builder) show_total_warns_and_errors_stats() {
|
||||
if b.pref.is_stats {
|
||||
println('checker summary: ${util.bold(b.checker.nr_errors.str())} V errors, ${util.bold(b.checker.nr_warnings.str())} V warnings')
|
||||
}
|
||||
}
|
||||
|
||||
fn (b &Builder) print_warnings_and_errors() {
|
||||
defer { b.show_total_warns_and_errors_stats() }
|
||||
if b.pref.output_mode == .silent {
|
||||
if b.checker.nr_errors > 0 {
|
||||
exit(1)
|
||||
@ -278,6 +285,7 @@ fn (b &Builder) print_warnings_and_errors() {
|
||||
return
|
||||
}
|
||||
}
|
||||
b.show_total_warns_and_errors_stats()
|
||||
exit(1)
|
||||
}
|
||||
if b.table.redefined_fns.len > 0 {
|
||||
@ -295,6 +303,7 @@ fn (b &Builder) print_warnings_and_errors() {
|
||||
}
|
||||
}
|
||||
}
|
||||
b.show_total_warns_and_errors_stats()
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
@ -304,10 +313,11 @@ fn verror(s string) {
|
||||
util.verror('builder error', s)
|
||||
}
|
||||
|
||||
pub fn (mut b Builder) timing_message(msg string) {
|
||||
pub fn (mut b Builder) timing_message(msg string, ms int) {
|
||||
formatted_message := '$msg: ${util.bold(ms.str())} ms'
|
||||
if b.pref.show_timings {
|
||||
println(msg)
|
||||
println(formatted_message)
|
||||
} else {
|
||||
b.info(msg)
|
||||
b.info(formatted_message)
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ pub fn (mut b Builder) gen_c(v_files []string) string {
|
||||
b.parse_imports()
|
||||
t1 := time.ticks()
|
||||
parse_time := t1 - t0
|
||||
b.timing_message('PARSE: ${parse_time}ms')
|
||||
b.timing_message('PARSE', parse_time)
|
||||
if b.pref.only_check_syntax {
|
||||
return ''
|
||||
}
|
||||
@ -21,14 +21,14 @@ pub fn (mut b Builder) gen_c(v_files []string) string {
|
||||
b.checker.check_files(b.parsed_files)
|
||||
t2 := time.ticks()
|
||||
check_time := t2 - t1
|
||||
b.timing_message('CHECK: ${check_time}ms')
|
||||
b.timing_message('CHECK', check_time)
|
||||
b.print_warnings_and_errors()
|
||||
// println('starting cgen...')
|
||||
// TODO: move gen.cgen() to c.gen()
|
||||
res := gen.cgen(b.parsed_files, b.table, b.pref)
|
||||
t3 := time.ticks()
|
||||
gen_time := t3 - t2
|
||||
b.timing_message('C GEN: ${gen_time}ms')
|
||||
b.timing_message('C GEN', gen_time)
|
||||
// println('cgen done')
|
||||
// println(res)
|
||||
return res
|
||||
|
@ -493,7 +493,7 @@ fn (mut v Builder) cc() {
|
||||
println('$ccompiler took $diff ms')
|
||||
println('=========\n')
|
||||
}
|
||||
v.timing_message('C ${ccompiler:3}: ${diff}ms')
|
||||
v.timing_message('C ${ccompiler:3}', diff)
|
||||
// Link it if we are cross compiling and need an executable
|
||||
/*
|
||||
if v.os == .linux && !linux_host && v.pref.build_mode != .build {
|
||||
|
@ -6,6 +6,7 @@ module builder
|
||||
import time
|
||||
import os
|
||||
import v.pref
|
||||
import v.util
|
||||
|
||||
fn get_vtmp_folder() string {
|
||||
mut vtmp := os.getenv('VTMP')
|
||||
@ -39,7 +40,7 @@ pub fn compile(command string, pref &pref.Preferences) {
|
||||
.x64 { b.compile_x64() }
|
||||
}
|
||||
if pref.is_stats {
|
||||
println('compilation took: $sw.elapsed().milliseconds() ms')
|
||||
println('compilation took: ${util.bold(sw.elapsed().milliseconds().str())} ms')
|
||||
}
|
||||
// running does not require the parsers anymore
|
||||
unsafe {
|
||||
|
@ -13,16 +13,16 @@ pub fn (mut b Builder) gen_js(v_files []string) string {
|
||||
b.parse_imports()
|
||||
t1 := time.ticks()
|
||||
parse_time := t1 - t0
|
||||
b.timing_message('PARSE: ${parse_time}ms')
|
||||
b.timing_message('PARSE', parse_time)
|
||||
b.checker.check_files(b.parsed_files)
|
||||
t2 := time.ticks()
|
||||
check_time := t2 - t1
|
||||
b.timing_message('CHECK: ${check_time}ms')
|
||||
b.timing_message('CHECK', check_time)
|
||||
b.print_warnings_and_errors()
|
||||
res := js.gen(b.parsed_files, b.table, b.pref)
|
||||
t3 := time.ticks()
|
||||
gen_time := t3 - t2
|
||||
b.timing_message('JS GEN: ${gen_time}ms')
|
||||
b.timing_message('JS GEN', gen_time)
|
||||
return res
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ pub fn (mut v Builder) cc_msvc() {
|
||||
return
|
||||
}
|
||||
diff := time.ticks() - ticks
|
||||
v.timing_message('C msvc: ${diff}ms')
|
||||
v.timing_message('C msvc', diff)
|
||||
if res.exit_code != 0 {
|
||||
verror(res.output)
|
||||
}
|
||||
|
@ -16,16 +16,16 @@ pub fn (mut b Builder) build_x64(v_files []string, out_file string) {
|
||||
b.parse_imports()
|
||||
t1 := time.ticks()
|
||||
parse_time := t1 - t0
|
||||
b.timing_message('PARSE: ${parse_time}ms')
|
||||
b.timing_message('PARSE', parse_time)
|
||||
|
||||
b.checker.check_files(b.parsed_files)
|
||||
t2 := time.ticks()
|
||||
check_time := t2 - t1
|
||||
b.timing_message('CHECK: ${check_time}ms')
|
||||
b.timing_message('CHECK', check_time)
|
||||
x64.gen(b.parsed_files, out_file, b.pref)
|
||||
t3 := time.ticks()
|
||||
gen_time := t3 - t2
|
||||
b.timing_message('x64 GEN: ${gen_time}ms')
|
||||
b.timing_message('x64 GEN', gen_time)
|
||||
}
|
||||
|
||||
pub fn (mut b Builder) compile_x64() {
|
||||
|
@ -43,10 +43,10 @@ pub fn (e &EManager) set_support_color(b bool) {
|
||||
unsafe {
|
||||
mut me := e
|
||||
me.support_color = b
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn bold(msg string) string {
|
||||
pub fn bold(msg string) string {
|
||||
if !emanager.support_color {
|
||||
return msg
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user