tools: support setting another SCANNER_MODE=parse_comments in parser_speed.v and scanner_speed.v

This commit is contained in:
Delyan Angelov 2024-01-21 08:16:25 +02:00
parent 135e2f1cc6
commit 3e8c53568d
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
2 changed files with 9 additions and 1 deletions

View file

@ -8,8 +8,12 @@ import v.scanner
import term import term
const skip_tests = os.getenv_opt('SKIP_TESTS') or { '' }.bool() const skip_tests = os.getenv_opt('SKIP_TESTS') or { '' }.bool()
const comments_mode = scanner.CommentsMode.from(os.getenv('SCANNER_MODE')) or {
scanner.CommentsMode.skip_comments
}
fn main() { fn main() {
dump(comments_mode)
files := os.args#[1..] files := os.args#[1..]
if files.len > 0 && files[0].starts_with('@') { if files.len > 0 && files[0].starts_with('@') {
lst_path := files[0].all_after('@') lst_path := files[0].all_after('@')

View file

@ -5,8 +5,12 @@ import v.scanner
import v.pref import v.pref
const skip_tests = os.getenv_opt('SKIP_TESTS') or { '' }.bool() const skip_tests = os.getenv_opt('SKIP_TESTS') or { '' }.bool()
const comments_mode = scanner.CommentsMode.from(os.getenv('SCANNER_MODE')) or {
scanner.CommentsMode.skip_comments
}
fn main() { fn main() {
dump(comments_mode)
files := os.args#[1..] files := os.args#[1..]
if files.len > 0 && files[0].starts_with('@') { if files.len > 0 && files[0].starts_with('@') {
lst_path := files[0].all_after('@') lst_path := files[0].all_after('@')
@ -47,7 +51,7 @@ fn process_files(files []string) ! {
} }
total_files++ total_files++
sw.restart() sw.restart()
s := scanner.new_scanner_file(f, .skip_comments, pref_)! s := scanner.new_scanner_file(f, comments_mode, pref_)!
f_us := sw.elapsed().microseconds() f_us := sw.elapsed().microseconds()
total_us += f_us total_us += f_us
total_bytes += s.text.len total_bytes += s.text.len