2022-06-02 13:35:13 +03:00
|
|
|
import os
|
|
|
|
import time
|
|
|
|
import v.scanner
|
|
|
|
import v.pref
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
files := os.args#[1..]
|
|
|
|
if files.len > 0 && files[0].starts_with('@') {
|
|
|
|
lst_path := files[0].all_after('@')
|
2022-10-16 09:28:57 +03:00
|
|
|
listed_files := os.read_file(lst_path)!.split('\n')
|
|
|
|
process_files(listed_files)!
|
2022-06-02 13:35:13 +03:00
|
|
|
return
|
|
|
|
}
|
2022-10-16 09:28:57 +03:00
|
|
|
process_files(files)!
|
2022-06-02 13:35:13 +03:00
|
|
|
}
|
|
|
|
|
2022-10-16 09:28:57 +03:00
|
|
|
fn process_files(files []string) ! {
|
2023-02-08 21:37:04 +03:00
|
|
|
mut pref_ := pref.new_preferences()
|
|
|
|
pref_.is_fmt = true
|
|
|
|
pref_.skip_warnings = true
|
|
|
|
pref_.output_mode = .silent
|
2022-06-02 13:35:13 +03:00
|
|
|
mut sw := time.new_stopwatch()
|
|
|
|
mut total_us := i64(0)
|
|
|
|
mut total_bytes := i64(0)
|
|
|
|
mut total_tokens := i64(0)
|
|
|
|
for f in files {
|
|
|
|
if f == '' {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if f.ends_with('_test.v') {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
sw.restart()
|
2023-02-08 21:37:04 +03:00
|
|
|
s := scanner.new_scanner_file(f, .skip_comments, pref_)!
|
2022-06-02 13:35:13 +03:00
|
|
|
f_us := sw.elapsed().microseconds()
|
|
|
|
total_us += f_us
|
|
|
|
total_bytes += s.text.len
|
|
|
|
total_tokens += s.all_tokens.len
|
2022-11-15 16:53:13 +03:00
|
|
|
println('${f_us:10}us ${s.all_tokens.len:10} ${s.text.len:10} ${(f64(s.text.len) / s.all_tokens.len):7.3f} ${f}')
|
2022-06-02 13:35:13 +03:00
|
|
|
}
|
|
|
|
println('${total_us:10}us ${total_tokens:10} ${total_bytes:10} ${(f64(total_tokens) / total_bytes):7.3f} | speed: ${(f64(total_bytes) / total_us):2.5f} MB/s')
|
|
|
|
}
|