mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
tools: fix find vlib/ -name "*.vv" | xtime xargs v -g run cmd/tools/measure/parser_speed.v
This commit is contained in:
parent
b6c7104d9e
commit
f4e9aa8e8b
3 changed files with 12 additions and 7 deletions
|
@ -21,7 +21,7 @@ fn main() {
|
|||
}
|
||||
|
||||
fn hline() {
|
||||
println('------------------------------------------------------------------------------------------------------------------------------------')
|
||||
println('---------------------------------------------------------------------------------------------------------------------------------------------------')
|
||||
}
|
||||
|
||||
fn theader() {
|
||||
|
@ -40,6 +40,7 @@ fn process_files(files []string) ! {
|
|||
mut total_tokens := i64(0)
|
||||
mut total_lines := i64(0)
|
||||
mut total_errors := i64(0)
|
||||
mut total_files := i64(0)
|
||||
for f in files {
|
||||
mut table := ast.new_table()
|
||||
if f == '' {
|
||||
|
@ -48,6 +49,7 @@ fn process_files(files []string) ! {
|
|||
if skip_tests && f.ends_with('_test.v') {
|
||||
continue
|
||||
}
|
||||
total_files++
|
||||
// do not measure the scanning, but only the parsing:
|
||||
mut p := new_parser(f, .skip_comments, table, pref_)
|
||||
///
|
||||
|
@ -67,7 +69,7 @@ fn process_files(files []string) ! {
|
|||
hline()
|
||||
speed_mb_s := term.colorize(term.bright_yellow, '${(f64(total_bytes) / total_us):6.3f} MB/s')
|
||||
speed_lines_s := term.colorize(term.bright_yellow, '${(1_000_000 * f64(total_lines) / total_us):10.1f} lines/s')
|
||||
println('${total_us:10}us ${total_tokens:10} ${total_bytes:10} ${total_lines:10} ${(f64(total_bytes) / total_tokens):13.3} ${total_errors:10} Parser speed: ${speed_mb_s}, ${speed_lines_s}, ${nthreads} thread(s)')
|
||||
println('${total_us:10}us ${total_tokens:10} ${total_bytes:10} ${total_lines:10} ${(f64(total_bytes) / total_tokens):13.3} ${total_errors:10} Parser speed: ${speed_mb_s}, ${speed_lines_s}, ${nthreads:3} thread(s), ${total_files:5} files.')
|
||||
}
|
||||
|
||||
fn new_parser(path string, comments_mode scanner.CommentsMode, table &ast.Table, pref_ &pref.Preferences) &parser.Parser {
|
||||
|
|
|
@ -18,7 +18,7 @@ fn main() {
|
|||
}
|
||||
|
||||
fn hline() {
|
||||
println('-------------------------------------------------------------------------------------------------------------------------------------')
|
||||
println('----------------------------------------------------------------------------------------------------------------------------------------------------')
|
||||
}
|
||||
|
||||
fn theader() {
|
||||
|
@ -37,6 +37,7 @@ fn process_files(files []string) ! {
|
|||
mut total_tokens := i64(0)
|
||||
mut total_lines := i64(0)
|
||||
mut total_errors := i64(0)
|
||||
mut total_files := i64(0)
|
||||
for f in files {
|
||||
if f == '' {
|
||||
continue
|
||||
|
@ -44,6 +45,7 @@ fn process_files(files []string) ! {
|
|||
if skip_tests && f.ends_with('_test.v') {
|
||||
continue
|
||||
}
|
||||
total_files++
|
||||
sw.restart()
|
||||
s := scanner.new_scanner_file(f, .skip_comments, pref_)!
|
||||
f_us := sw.elapsed().microseconds()
|
||||
|
@ -59,5 +61,5 @@ fn process_files(files []string) ! {
|
|||
hline()
|
||||
speed_mb_s := term.colorize(term.bright_yellow, '${(f64(total_bytes) / total_us):6.3f} MB/s')
|
||||
speed_lines_s := term.colorize(term.bright_yellow, '${(1_000_000 * f64(total_lines) / total_us):10.1f} lines/s')
|
||||
println('${total_us:10}us ${total_tokens:10} ${total_bytes:10} ${total_lines:10} ${(f64(total_bytes) / total_tokens):13.3} ${total_errors:10} Scanner speed: ${speed_mb_s}, ${speed_lines_s}, ${nthreads} thread(s)')
|
||||
println('${total_us:10}us ${total_tokens:10} ${total_bytes:10} ${total_lines:10} ${(f64(total_bytes) / total_tokens):13.3} ${total_errors:10} Scanner speed: ${speed_mb_s}, ${speed_lines_s}, ${nthreads:3} thread(s), ${total_files:5} files.')
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ import os
|
|||
fn (mut p Parser) call_expr(language ast.Language, mod string) ast.CallExpr {
|
||||
first_pos := p.tok.pos()
|
||||
mut name := if language == .js { p.check_js_name() } else { p.check_name() }
|
||||
mut is_static_type_method := language == .v && name[0].is_capital() && p.tok.kind == .dot
|
||||
mut is_static_type_method := language == .v && name.len > 0 && name[0].is_capital()
|
||||
&& p.tok.kind == .dot
|
||||
if is_static_type_method {
|
||||
p.check(.dot)
|
||||
name = name + '__static__' + p.check_name()
|
||||
|
@ -1133,10 +1134,10 @@ fn (mut p Parser) closure_vars() []ast.Param {
|
|||
if p.table.global_scope.known_global(var_name) {
|
||||
p.error_with_pos('no need to capture global variable `${var_name}` in closure',
|
||||
p.prev_tok.pos())
|
||||
continue
|
||||
return []
|
||||
}
|
||||
p.error_with_pos('undefined ident: `${var_name}`', p.prev_tok.pos())
|
||||
continue
|
||||
return []
|
||||
}
|
||||
var.is_used = true
|
||||
if is_mut {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue