Implements --label option for python profiler (#34)
* Implements --label option for python profiler
- removes '-a', '-f', and '-l' options in favor of '--label args file line' for consistency with omnitrace exe
* cmake formatting
* Bump version to 1.1.0
[ROCm/rocprofiler-systems commit: 017e794d63]
This commit is contained in:
zatwierdzone przez
GitHub
rodzic
ac25b485e7
commit
04edcf33c3
@@ -1 +1 @@
|
||||
1.0.1
|
||||
1.1.0
|
||||
|
||||
@@ -49,24 +49,21 @@ python3.8 -m omnitrace --help
|
||||
Use `omnitrace-python --help` to view the available options:
|
||||
|
||||
```console
|
||||
usage: omnitrace [-h] [-b] [-c FILE] [-s FILE] [--trace-c [BOOL]] [-a [BOOL]] [-l [BOOL]] [-f [BOOL]] [-F [BOOL]] [-I FUNC [FUNC ...]] [-E FUNC [FUNC ...]] [-R FUNC [FUNC ...]] [-MI FILE [FILE ...]] [-ME FILE [FILE ...]] [-MR FILE [FILE ...]] [-v VERBOSITY]
|
||||
usage: omnitrace [-h] [-v VERBOSITY] [-b] [-c FILE] [-s FILE] [-F [BOOL]] [--label [{args,file,line} [{args,file,line} ...]]] [-I FUNC [FUNC ...]] [-E FUNC [FUNC ...]] [-R FUNC [FUNC ...]] [-MI FILE [FILE ...]] [-ME FILE [FILE ...]] [-MR FILE [FILE ...]] [--trace-c [BOOL]]
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-v VERBOSITY, --verbosity VERBOSITY
|
||||
Logging verbosity
|
||||
-b, --builtin Put 'profile' in the builtins. Use '@profile' to decorate a single function, or 'with profile:' to profile a single section of code.
|
||||
-c FILE, --config FILE
|
||||
Omnitrace configuration file
|
||||
-s FILE, --setup FILE
|
||||
Code to execute before the code to profile
|
||||
--trace-c [BOOL] Enable profiling C functions
|
||||
-a [BOOL], --include-args [BOOL]
|
||||
Encode the argument values
|
||||
-l [BOOL], --include-line [BOOL]
|
||||
Encode the function line number
|
||||
-f [BOOL], --include-file [BOOL]
|
||||
Encode the function filename
|
||||
-F [BOOL], --full-filepath [BOOL]
|
||||
Encode the full function filename (instead of basename)
|
||||
--label [{args,file,line} [{args,file,line} ...]]
|
||||
Encode the function arguments, filename, and/or line number into the profiling function label
|
||||
-I FUNC [FUNC ...], --function-include FUNC [FUNC ...]
|
||||
Include any entries with these function names
|
||||
-E FUNC [FUNC ...], --function-exclude FUNC [FUNC ...]
|
||||
@@ -79,8 +76,7 @@ optional arguments:
|
||||
Filter out any entries from these files
|
||||
-MR FILE [FILE ...], --module-restrict FILE [FILE ...]
|
||||
Select only entries from these files
|
||||
-v VERBOSITY, --verbosity VERBOSITY
|
||||
Logging verbosity
|
||||
--trace-c [BOOL] Enable profiling C functions
|
||||
|
||||
usage: python3 -m omnitrace <OMNITRACE_ARGS> -- <SCRIPT> <SCRIPT_ARGS>
|
||||
```
|
||||
|
||||
@@ -93,6 +93,14 @@ def parse_args(args=None):
|
||||
else:
|
||||
raise argparse.ArgumentTypeError("Boolean value expected.")
|
||||
|
||||
_default_label = []
|
||||
if _profiler_config.include_args:
|
||||
_default_label.append("args")
|
||||
if _profiler_config.include_filename:
|
||||
_default_label.append("file")
|
||||
if _profiler_config.include_line:
|
||||
_default_label.append("line")
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
"omnitrace",
|
||||
add_help=True,
|
||||
@@ -100,6 +108,13 @@ def parse_args(args=None):
|
||||
os.path.basename(sys.executable)
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"-v",
|
||||
"--verbosity",
|
||||
type=int,
|
||||
default=_profiler_config.verbosity,
|
||||
help="Logging verbosity",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-b",
|
||||
"--builtin",
|
||||
@@ -124,45 +139,6 @@ def parse_args(args=None):
|
||||
metavar="FILE",
|
||||
help="Code to execute before the code to profile",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--trace-c",
|
||||
type=str2bool,
|
||||
nargs="?",
|
||||
metavar="BOOL",
|
||||
const=True,
|
||||
default=_profiler_config.trace_c,
|
||||
help="Enable profiling C functions",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-a",
|
||||
"--include-args",
|
||||
type=str2bool,
|
||||
nargs="?",
|
||||
metavar="BOOL",
|
||||
const=True,
|
||||
default=_profiler_config.include_args,
|
||||
help="Encode the argument values",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-l",
|
||||
"--include-line",
|
||||
type=str2bool,
|
||||
nargs="?",
|
||||
metavar="BOOL",
|
||||
const=True,
|
||||
default=_profiler_config.include_line,
|
||||
help="Encode the function line number",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-f",
|
||||
"--include-file",
|
||||
type=str2bool,
|
||||
nargs="?",
|
||||
metavar="BOOL",
|
||||
const=True,
|
||||
default=_profiler_config.include_filename,
|
||||
help="Encode the function filename",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-F",
|
||||
"--full-filepath",
|
||||
@@ -173,6 +149,14 @@ def parse_args(args=None):
|
||||
default=_profiler_config.full_filepath,
|
||||
help="Encode the full function filename (instead of basename)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--label",
|
||||
type=str,
|
||||
choices=("args", "file", "line"),
|
||||
nargs="*",
|
||||
default=_default_label,
|
||||
help="Encode the function arguments, filename, and/or line number into the profiling function label",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-I",
|
||||
"--function-include",
|
||||
@@ -228,11 +212,13 @@ def parse_args(args=None):
|
||||
help="Select only entries from these files",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-v",
|
||||
"--verbosity",
|
||||
type=int,
|
||||
default=_profiler_config.verbosity,
|
||||
help="Logging verbosity",
|
||||
"--trace-c",
|
||||
type=str2bool,
|
||||
nargs="?",
|
||||
metavar="BOOL",
|
||||
const=True,
|
||||
default=_profiler_config.trace_c,
|
||||
help="Enable profiling C functions",
|
||||
)
|
||||
|
||||
return parser.parse_args(args)
|
||||
@@ -326,9 +312,9 @@ def main():
|
||||
from .libpyomnitrace.profiler import config as _profiler_config
|
||||
|
||||
_profiler_config.trace_c = opts.trace_c
|
||||
_profiler_config.include_args = opts.include_args
|
||||
_profiler_config.include_line = opts.include_line
|
||||
_profiler_config.include_filename = opts.include_file
|
||||
_profiler_config.include_args = "args" in opts.label
|
||||
_profiler_config.include_line = "line" in opts.label
|
||||
_profiler_config.include_filename = "file" in opts.label
|
||||
_profiler_config.full_filepath = opts.full_filepath
|
||||
_profiler_config.include_functions = opts.function_include
|
||||
_profiler_config.include_modules = opts.module_include
|
||||
|
||||
@@ -808,7 +808,7 @@ foreach(_VERSION ${OMNITRACE_PYTHON_VERSIONS})
|
||||
PYTHON_EXECUTABLE ${_PYTHON_EXECUTABLE}
|
||||
PYTHON_VERSION ${_VERSION}
|
||||
FILE ${CMAKE_SOURCE_DIR}/examples/python/external.py
|
||||
PROFILE_ARGS -f
|
||||
PROFILE_ARGS "--label" "file"
|
||||
RUN_ARGS -v 10 -n 5
|
||||
ENVIRONMENT "${_python_environment}")
|
||||
|
||||
@@ -826,7 +826,7 @@ foreach(_VERSION ${OMNITRACE_PYTHON_VERSIONS})
|
||||
PYTHON_EXECUTABLE ${_PYTHON_EXECUTABLE}
|
||||
PYTHON_VERSION ${_VERSION}
|
||||
FILE ${CMAKE_SOURCE_DIR}/examples/python/builtin.py
|
||||
PROFILE_ARGS -b -l -f
|
||||
PROFILE_ARGS "-b" "--label" "file" "line"
|
||||
RUN_ARGS -v 10 -n 5
|
||||
ENVIRONMENT "${_python_environment}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user