mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
test-cleancode: add benchmark
and bitfield
(#7613)
This commit is contained in:
parent
e8b5fa2134
commit
6f194f2fa9
@ -20,7 +20,9 @@ const (
|
|||||||
vfmt_verify_list = [
|
vfmt_verify_list = [
|
||||||
'cmd/tools/vdoc/vdoc.v',
|
'cmd/tools/vdoc/vdoc.v',
|
||||||
'cmd/v/v.v',
|
'cmd/v/v.v',
|
||||||
'vlib/arrays',
|
'vlib/arrays/',
|
||||||
|
'vlib/benchmark/',
|
||||||
|
'vlib/bitfield/',
|
||||||
'vlib/builtin/array.v',
|
'vlib/builtin/array.v',
|
||||||
'vlib/builtin/array_test.v',
|
'vlib/builtin/array_test.v',
|
||||||
'vlib/builtin/map.v',
|
'vlib/builtin/map.v',
|
||||||
|
@ -133,25 +133,33 @@ pub fn (b &Benchmark) step_message_with_label_and_duration(label string, msg str
|
|||||||
if b.nexpected_steps > 1 {
|
if b.nexpected_steps > 1 {
|
||||||
mut sprogress := ''
|
mut sprogress := ''
|
||||||
if b.nexpected_steps < 10 {
|
if b.nexpected_steps < 10 {
|
||||||
sprogress = if b.no_cstep { 'TMP1/${b.nexpected_steps:1d}' } else {
|
sprogress = if b.no_cstep {
|
||||||
|
'TMP1/${b.nexpected_steps:1d}'
|
||||||
|
} else {
|
||||||
'${b.cstep:1d}/${b.nexpected_steps:1d}'
|
'${b.cstep:1d}/${b.nexpected_steps:1d}'
|
||||||
}
|
}
|
||||||
} else if b.nexpected_steps >= 10 && b.nexpected_steps < 100 {
|
} else if b.nexpected_steps >= 10 && b.nexpected_steps < 100 {
|
||||||
sprogress = if b.no_cstep { 'TMP2/${b.nexpected_steps:2d}' } else {
|
sprogress = if b.no_cstep {
|
||||||
|
'TMP2/${b.nexpected_steps:2d}'
|
||||||
|
} else {
|
||||||
'${b.cstep:2d}/${b.nexpected_steps:2d}'
|
'${b.cstep:2d}/${b.nexpected_steps:2d}'
|
||||||
}
|
}
|
||||||
} else if b.nexpected_steps >= 100 && b.nexpected_steps < 1000 {
|
} else if b.nexpected_steps >= 100 && b.nexpected_steps < 1000 {
|
||||||
sprogress = if b.no_cstep { 'TMP3/${b.nexpected_steps:3d}' } else {
|
sprogress = if b.no_cstep {
|
||||||
|
'TMP3/${b.nexpected_steps:3d}'
|
||||||
|
} else {
|
||||||
'${b.cstep:3d}/${b.nexpected_steps:3d}'
|
'${b.cstep:3d}/${b.nexpected_steps:3d}'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sprogress = if b.no_cstep { 'TMP4/${b.nexpected_steps:4d}' } else {
|
sprogress = if b.no_cstep {
|
||||||
|
'TMP4/${b.nexpected_steps:4d}'
|
||||||
|
} else {
|
||||||
'${b.cstep:4d}/${b.nexpected_steps:4d}'
|
'${b.cstep:4d}/${b.nexpected_steps:4d}'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '${label:-5s} [${sprogress}] ${timed_line}'
|
return '${label:-5s} [$sprogress] $timed_line'
|
||||||
}
|
}
|
||||||
return '${label:-5s}${timed_line}'
|
return '${label:-5s}$timed_line'
|
||||||
}
|
}
|
||||||
|
|
||||||
// step_message_with_label returns a string describing the current step using current time as duration.
|
// step_message_with_label returns a string describing the current step using current time as duration.
|
||||||
@ -181,7 +189,9 @@ pub fn (b &Benchmark) step_message_skip(msg string) string {
|
|||||||
|
|
||||||
// total_message returns a string with total summary of the benchmark run.
|
// total_message returns a string with total summary of the benchmark run.
|
||||||
pub fn (b &Benchmark) total_message(msg string) string {
|
pub fn (b &Benchmark) total_message(msg string) string {
|
||||||
mut tmsg := '${msg}\n ok, fail, skip, total = ' + term.ok_message('${b.nok:5d}') + ', ' + if b.nfail > 0 { term.red('${b.nfail:5d}') } else { '${b.nfail:5d}' } + ', ' + if b.nskip > 0 { term.bright_yellow('${b.nskip:5d}') } else { '${b.nskip:5d}' } + ', ' + '${b.ntotal:5d}'
|
mut tmsg := '$msg\n ok, fail, skip, total = ' + term.ok_message('${b.nok:5d}') +
|
||||||
|
', ' + if b.nfail > 0 { term.red('${b.nfail:5d}') } else { '${b.nfail:5d}' } + ', ' + if b.nskip >
|
||||||
|
0 { term.bright_yellow('${b.nskip:5d}') } else { '${b.nskip:5d}' } + ', ' + '${b.ntotal:5d}'
|
||||||
if b.verbose {
|
if b.verbose {
|
||||||
tmsg = '<=== total time spent $tmsg'
|
tmsg = '<=== total time spent $tmsg'
|
||||||
}
|
}
|
||||||
@ -203,7 +213,7 @@ pub fn (b &Benchmark) total_duration() i64 {
|
|||||||
// tdiff_in_ms prefixes `s` with a time difference calculation.
|
// tdiff_in_ms prefixes `s` with a time difference calculation.
|
||||||
fn (b &Benchmark) tdiff_in_ms(s string, tdiff i64) string {
|
fn (b &Benchmark) tdiff_in_ms(s string, tdiff i64) string {
|
||||||
if b.verbose {
|
if b.verbose {
|
||||||
return '${f64(tdiff)/1000.0:9.3f} ms $s'
|
return '${f64(tdiff) / 1000.0:9.3f} ms $s'
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user