15.2.106. camcops_server.cc_modules.cc_debug¶
camcops_server/cc_modules/cc_debug.py
Copyright (C) 2012, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
This file is part of CamCOPS.
CamCOPS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
CamCOPS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
Debugging utilities
- camcops_server.cc_modules.cc_debug.makefunc_trace_unique_calls(file_only: bool = False) Callable[[frame, str, Any], Optional[Callable]] [source]¶
Creates a function that you can use as an argument to
sys.settrace()
. When you execute a trace, it shows only new call to each function.- Parameters
file_only – Shows files called only, not functions with line numbers.
- camcops_server.cc_modules.cc_debug.profile(func)[source]¶
Decorator to generate profiler output for slow code from camcops_server.cc_debug import profile.
Add @profile to the function you want to profile. Will generate a file called <function name>.profile.
Can be visualised with e.g. SnakeViz (pip install snakeviz)