profile: support for -profile-no-inline (with it, [inline] fns will not get profiled)

pull/4788/head
Delyan Angelov 2020-05-08 14:59:48 +03:00
parent 847a1035a5
commit 4c320e1512
4 changed files with 12 additions and 1 deletions

View File

@ -75,6 +75,9 @@ The build flags are shared by the build and run commands:
d) the function name
NB: if you want to output the profile info to stdout, use `-profile -`.
-profile-no-inline
Skip [inline] functions when profiling.
-stats
Enable more detailed statistics reporting, while compiling test files.
You can use that with `v test` too, for example:

View File

@ -150,6 +150,9 @@ fn parse_args(args []string) (&pref.Preferences, string) {
res.is_prof = true
i++
}
'-profile-no-inline' {
res.profile_no_inline = true
}
'-prod' {
res.is_prod = true
}

View File

@ -12,6 +12,10 @@ fn (mut g Gen) profile_fn(fn_name string, is_main bool){
g.writeln('\tatexit(vprint_profile_stats);')
g.writeln('')
}
if g.pref.profile_no_inline && g.attr == 'inline' {
g.defer_profile_code = ''
return
}
if fn_name.starts_with('time.vpc_now') {
g.defer_profile_code = ''
} else {

View File

@ -33,6 +33,7 @@ pub mut:
is_shared bool // an ordinary shared library, -shared, no matter if it is live or not
is_prof bool // benchmark every function
profile_file string // the profile results will be stored inside profile_file
profile_no_inline bool // when true, [inline] functions would not be profiled
translated bool // `v translate doom.v` are we running V code translated from C? allow globals, ++ expressions, etc
is_prod bool // use "-O2"
obfuscate bool // `v -obf program.v`, renames functions to "f_XXX"