diff --git a/cmd/v/help/build.txt b/cmd/v/help/build.txt index 3aa323df3c..8a45dd7612 100644 --- a/cmd/v/help/build.txt +++ b/cmd/v/help/build.txt @@ -74,7 +74,10 @@ The build flags are shared by the build and run commands: c) an average for each function (i.e. (b) / (a) ) 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: diff --git a/cmd/v/v.v b/cmd/v/v.v index f7dc229dcd..bbdcb765a8 100644 --- a/cmd/v/v.v +++ b/cmd/v/v.v @@ -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 } diff --git a/vlib/v/gen/profile.v b/vlib/v/gen/profile.v index 35a5374a74..945dde9e18 100644 --- a/vlib/v/gen/profile.v +++ b/vlib/v/gen/profile.v @@ -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 { diff --git a/vlib/v/pref/pref.v b/vlib/v/pref/pref.v index 639333ecf9..97bb16fb45 100644 --- a/vlib/v/pref/pref.v +++ b/vlib/v/pref/pref.v @@ -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"