compiler: move timing_start/timing_measure to util.timing_start/util.timing_measure
parent
25a3873019
commit
16dffc7c1d
|
@ -27,7 +27,6 @@ pub mut:
|
||||||
parsed_files []ast.File
|
parsed_files []ast.File
|
||||||
cached_msvc MsvcResult
|
cached_msvc MsvcResult
|
||||||
table &table.Table
|
table &table.Table
|
||||||
timers &util.Timers = util.new_timers(false)
|
|
||||||
ccoptions CcompilerOptions
|
ccoptions CcompilerOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +49,7 @@ pub fn new_builder(pref &pref.Preferences) Builder {
|
||||||
valid: false
|
valid: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
util.timing_set_should_print(pref.show_timings || pref.is_verbose)
|
||||||
return Builder{
|
return Builder{
|
||||||
pref: pref
|
pref: pref
|
||||||
table: table
|
table: table
|
||||||
|
@ -64,7 +64,6 @@ pub fn new_builder(pref &pref.Preferences) Builder {
|
||||||
100
|
100
|
||||||
}
|
}
|
||||||
cached_msvc: msvc
|
cached_msvc: msvc
|
||||||
timers: util.new_timers(pref.show_timings || pref.is_verbose)
|
|
||||||
}
|
}
|
||||||
// max_nr_errors: pref.error_limit ?? 100 TODO potential syntax?
|
// max_nr_errors: pref.error_limit ?? 100 TODO potential syntax?
|
||||||
}
|
}
|
||||||
|
@ -403,11 +402,3 @@ fn error_with_pos(s string, fpath string, pos token.Position) {
|
||||||
fn verror(s string) {
|
fn verror(s string) {
|
||||||
util.verror('builder error', s)
|
util.verror('builder error', s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut b Builder) timing_start(label string) {
|
|
||||||
b.timers.start(label)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (mut b Builder) timing_measure(label string) {
|
|
||||||
b.timers.show(label)
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,27 +3,28 @@ module builder
|
||||||
import os
|
import os
|
||||||
import v.parser
|
import v.parser
|
||||||
import v.pref
|
import v.pref
|
||||||
|
import v.util
|
||||||
import v.gen.c
|
import v.gen.c
|
||||||
|
|
||||||
pub fn (mut b Builder) gen_c(v_files []string) string {
|
pub fn (mut b Builder) gen_c(v_files []string) string {
|
||||||
b.timing_start('PARSE')
|
util.timing_start('PARSE')
|
||||||
b.parsed_files = parser.parse_files(v_files, b.table, b.pref, b.global_scope)
|
b.parsed_files = parser.parse_files(v_files, b.table, b.pref, b.global_scope)
|
||||||
b.parse_imports()
|
b.parse_imports()
|
||||||
b.timing_measure('PARSE')
|
util.timing_measure('PARSE')
|
||||||
if b.pref.only_check_syntax {
|
if b.pref.only_check_syntax {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
b.timing_start('CHECK')
|
util.timing_start('CHECK')
|
||||||
b.generic_struct_insts_to_concrete()
|
b.generic_struct_insts_to_concrete()
|
||||||
b.checker.check_files(b.parsed_files)
|
b.checker.check_files(b.parsed_files)
|
||||||
b.timing_measure('CHECK')
|
util.timing_measure('CHECK')
|
||||||
//
|
//
|
||||||
b.print_warnings_and_errors()
|
b.print_warnings_and_errors()
|
||||||
// TODO: move gen.cgen() to c.gen()
|
// TODO: move gen.cgen() to c.gen()
|
||||||
b.timing_start('C GEN')
|
util.timing_start('C GEN')
|
||||||
res := c.gen(b.parsed_files, b.table, b.pref)
|
res := c.gen(b.parsed_files, b.table, b.pref)
|
||||||
b.timing_measure('C GEN')
|
util.timing_measure('C GEN')
|
||||||
// println('cgen done')
|
// println('cgen done')
|
||||||
// println(res)
|
// println(res)
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -633,14 +633,14 @@ fn (mut v Builder) cc() {
|
||||||
v.show_cc(cmd, response_file, response_file_content)
|
v.show_cc(cmd, response_file, response_file_content)
|
||||||
// Run
|
// Run
|
||||||
ccompiler_label := 'C ${os.file_name(ccompiler):3}'
|
ccompiler_label := 'C ${os.file_name(ccompiler):3}'
|
||||||
v.timing_start(ccompiler_label)
|
util.timing_start(ccompiler_label)
|
||||||
res := os.exec(cmd) or {
|
res := os.exec(cmd) or {
|
||||||
println('C compilation failed.')
|
println('C compilation failed.')
|
||||||
os.chdir(original_pwd)
|
os.chdir(original_pwd)
|
||||||
verror(err)
|
verror(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v.timing_measure(ccompiler_label)
|
util.timing_measure(ccompiler_label)
|
||||||
if v.pref.show_c_output {
|
if v.pref.show_c_output {
|
||||||
v.show_c_compiler_output(res)
|
v.show_c_compiler_output(res)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,23 +3,24 @@ module builder
|
||||||
import os
|
import os
|
||||||
import v.parser
|
import v.parser
|
||||||
import v.pref
|
import v.pref
|
||||||
|
import v.util
|
||||||
import v.gen.js
|
import v.gen.js
|
||||||
|
|
||||||
pub fn (mut b Builder) gen_js(v_files []string) string {
|
pub fn (mut b Builder) gen_js(v_files []string) string {
|
||||||
b.timing_start('PARSE')
|
util.timing_start('PARSE')
|
||||||
b.parsed_files = parser.parse_files(v_files, b.table, b.pref, b.global_scope)
|
b.parsed_files = parser.parse_files(v_files, b.table, b.pref, b.global_scope)
|
||||||
b.parse_imports()
|
b.parse_imports()
|
||||||
b.timing_measure('PARSE')
|
util.timing_measure('PARSE')
|
||||||
//
|
//
|
||||||
b.timing_start('CHECK')
|
util.timing_start('CHECK')
|
||||||
b.checker.check_files(b.parsed_files)
|
b.checker.check_files(b.parsed_files)
|
||||||
b.timing_measure('CHECK')
|
util.timing_measure('CHECK')
|
||||||
//
|
//
|
||||||
b.print_warnings_and_errors()
|
b.print_warnings_and_errors()
|
||||||
//
|
//
|
||||||
b.timing_start('JS GEN')
|
util.timing_start('JS GEN')
|
||||||
res := js.gen(b.parsed_files, b.table, b.pref)
|
res := js.gen(b.parsed_files, b.table, b.pref)
|
||||||
b.timing_measure('JS GEN')
|
util.timing_measure('JS GEN')
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ module builder
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import v.pref
|
import v.pref
|
||||||
|
import v.util
|
||||||
import v.cflag
|
import v.cflag
|
||||||
|
|
||||||
#flag windows -l shell32
|
#flag windows -l shell32
|
||||||
|
@ -301,13 +302,13 @@ pub fn (mut v Builder) cc_msvc() {
|
||||||
// It is hard to see it at first, but the quotes above ARE balanced :-| ...
|
// It is hard to see it at first, but the quotes above ARE balanced :-| ...
|
||||||
// Also the double quotes at the start ARE needed.
|
// Also the double quotes at the start ARE needed.
|
||||||
v.show_cc(cmd, out_name_cmd_line, args)
|
v.show_cc(cmd, out_name_cmd_line, args)
|
||||||
v.timing_start('C msvc')
|
util.timing_start('C msvc')
|
||||||
res := os.exec(cmd) or {
|
res := os.exec(cmd) or {
|
||||||
println(err)
|
println(err)
|
||||||
verror('msvc error')
|
verror('msvc error')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v.timing_measure('C msvc')
|
util.timing_measure('C msvc')
|
||||||
if v.pref.show_c_output {
|
if v.pref.show_c_output {
|
||||||
v.show_c_compiler_output(res)
|
v.show_c_compiler_output(res)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,6 +2,7 @@ module builder
|
||||||
|
|
||||||
import v.parser
|
import v.parser
|
||||||
import v.pref
|
import v.pref
|
||||||
|
import v.util
|
||||||
import v.gen.x64
|
import v.gen.x64
|
||||||
|
|
||||||
pub fn (mut b Builder) build_x64(v_files []string, out_file string) {
|
pub fn (mut b Builder) build_x64(v_files []string, out_file string) {
|
||||||
|
@ -10,18 +11,18 @@ pub fn (mut b Builder) build_x64(v_files []string, out_file string) {
|
||||||
println('You are not on a Linux system, so you will not ' +
|
println('You are not on a Linux system, so you will not ' +
|
||||||
'be able to run the resulting executable')
|
'be able to run the resulting executable')
|
||||||
}
|
}
|
||||||
b.timing_start('PARSE')
|
util.timing_start('PARSE')
|
||||||
b.parsed_files = parser.parse_files(v_files, b.table, b.pref, b.global_scope)
|
b.parsed_files = parser.parse_files(v_files, b.table, b.pref, b.global_scope)
|
||||||
b.parse_imports()
|
b.parse_imports()
|
||||||
b.timing_measure('PARSE')
|
util.timing_measure('PARSE')
|
||||||
//
|
//
|
||||||
b.timing_start('CHECK')
|
util.timing_start('CHECK')
|
||||||
b.checker.check_files(b.parsed_files)
|
b.checker.check_files(b.parsed_files)
|
||||||
b.timing_measure('CHECK')
|
util.timing_measure('CHECK')
|
||||||
//
|
//
|
||||||
b.timing_start('x64 GEN')
|
util.timing_start('x64 GEN')
|
||||||
x64.gen(b.parsed_files, b.table, out_file, b.pref)
|
x64.gen(b.parsed_files, b.table, out_file, b.pref)
|
||||||
b.timing_measure('x64 GEN')
|
util.timing_measure('x64 GEN')
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut b Builder) compile_x64() {
|
pub fn (mut b Builder) compile_x64() {
|
||||||
|
|
|
@ -2,6 +2,7 @@ module checker
|
||||||
|
|
||||||
import v.ast
|
import v.ast
|
||||||
import v.table
|
import v.table
|
||||||
|
import v.util
|
||||||
import v.checker.mark_used_walker
|
import v.checker.mark_used_walker
|
||||||
|
|
||||||
// mark_used walks the AST, starting at main() and marks all used fns transitively
|
// mark_used walks the AST, starting at main() and marks all used fns transitively
|
||||||
|
@ -10,7 +11,7 @@ fn (mut c Checker) mark_used(ast_files []ast.File) {
|
||||||
// c.is_recursive = true
|
// c.is_recursive = true
|
||||||
// c.fn_decl(mut c.table2.main_fn_decl_node)
|
// c.fn_decl(mut c.table2.main_fn_decl_node)
|
||||||
|
|
||||||
// c.timing_measure(@FN)
|
util.timing_start(@STRUCT + '.' + @FN)
|
||||||
mut walker := mark_used_walker.Walker{
|
mut walker := mark_used_walker.Walker{
|
||||||
files: ast_files
|
files: ast_files
|
||||||
}
|
}
|
||||||
|
@ -100,7 +101,7 @@ fn (mut c Checker) mark_used(ast_files []ast.File) {
|
||||||
c.table.used_fns['main.can_use_relative_paths'] = true
|
c.table.used_fns['main.can_use_relative_paths'] = true
|
||||||
//
|
//
|
||||||
// eprintln('>>> c.table.used_fns: $c.table.used_fns')
|
// eprintln('>>> c.table.used_fns: $c.table.used_fns')
|
||||||
// c.timing_measure(@FN)
|
util.timing_measure(@STRUCT + '.' + @FN)
|
||||||
|
|
||||||
// println(walker.used_fns)
|
// println(walker.used_fns)
|
||||||
// c.walk(ast_files)
|
// c.walk(ast_files)
|
||||||
|
|
|
@ -19,6 +19,25 @@ pub fn new_timers(should_print bool) &Timers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const timers = new_timers(false)
|
||||||
|
|
||||||
|
pub fn get_timers() &Timers {
|
||||||
|
return util.timers
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn timing_start(label string) {
|
||||||
|
get_timers().start(label)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn timing_measure(label string) {
|
||||||
|
get_timers().show(label)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn timing_set_should_print(should_print bool) {
|
||||||
|
mut t := util.timers
|
||||||
|
t.should_print = should_print
|
||||||
|
}
|
||||||
|
|
||||||
pub fn (mut t Timers) start(name string) {
|
pub fn (mut t Timers) start(name string) {
|
||||||
sw := time.new_stopwatch({})
|
sw := time.new_stopwatch({})
|
||||||
t.swatches[name] = sw
|
t.swatches[name] = sw
|
||||||
|
|
Loading…
Reference in New Issue