1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tools/fast: add "V lines" and "V lines/s"

This commit is contained in:
Alexander Medvednikov
2021-04-30 15:31:20 +03:00
parent d236d6a473
commit e949d4b26c
6 changed files with 26 additions and 11 deletions

View File

@@ -38,6 +38,7 @@ fn main() {
// exec('git checkout $commit')
println(' Building vprod...')
exec('v -o $vdir/vprod -prod $vdir/cmd/v')
// exec('v -o $vdir/vprod $vdir/cmd/v') // for faster debugging
diff1 := measure('$vdir/vprod -cc clang -o v.c -show-timings $vdir/cmd/v', 'v.c')
mut tcc_path := 'tcc'
$if freebsd {
@@ -48,7 +49,7 @@ fn main() {
diff4 := measure('$vdir/vprod -cc clang $vdir/examples/hello_world.v', 'hello.v')
vc_size := os.file_size('v.c') / 1000
// scan/parse/check/cgen
scan, parse, check, cgen := measure_steps(vdir)
scan, parse, check, cgen, vlines := measure_steps(vdir)
// println('Building V took ${diff}ms')
commit_date := exec('git log -n1 --pretty="format:%at" $commit')
date := time.unix(commit_date.int())
@@ -69,6 +70,8 @@ fn main() {
<td>${check}ms</td>
<td>${cgen}ms</td>
<td>${scan}ms</td>
<td>$vlines</td>
<td>${int(f64(vlines) / f64(diff1) * 1000.0)} lines/s</td>
</tr>\n' +
table.trim_space()
out.writeln(table) ?
@@ -116,9 +119,10 @@ fn measure(cmd string, description string) int {
return int(sum / 3)
}
fn measure_steps(vdir string) (int, int, int, int) {
resp := os.execute_or_panic('$vdir/vprod -o v.c -show-timings $vdir/cmd/v')
mut scan, mut parse, mut check, mut cgen := 0, 0, 0, 0
fn measure_steps(vdir string) (int, int, int, int, int) {
resp := os.execute_or_panic('$vdir/vprod -o v.c -show-timings -stats $vdir/cmd/v')
mut scan, mut parse, mut check, mut cgen, mut vlines := 0, 0, 0, 0, 0
lines := resp.output.split_into_lines()
if lines.len == 3 {
parse = lines[0].before('.').int()
@@ -140,8 +144,16 @@ fn measure_steps(vdir string) (int, int, int, int) {
if line[1] == 'C GEN' {
cgen = line[0].int()
}
} else {
// Fetch number of V lines
if line[0].contains('V') && line[0].contains('source') && line[0].contains('size') {
start := line[0].index(':') or { 0 }
end := line[0].index('lines,') or { 0 }
s := line[0][start + 1..end]
vlines = s.trim_space().int()
}
}
}
}
return scan, parse, check, cgen
return scan, parse, check, cgen, vlines
}

View File

@@ -60,4 +60,6 @@ Source code: <a target=blank href='https://github.com/vlang/v/blob/master/cmd/to
<td style='width:55px'>check</td>
<td style='width:55px'>cgen</td>
<td style='width:55px'>scan</td>
<td style='width:55px'>V lines</td>
<td style='width:55px'>V lines/s</td>
</tr>