Run a statement through the python code profiler. **Usage, in line mode**:: %prun [options] statement **Usage, in cell mode**:: %%prun [options] [statement] code... code... In cell mode, the additional code lines are appended to th
(self, parameter_s='', cell=None)
| 203 | @no_var_expand |
| 204 | @line_cell_magic |
| 205 | def prun(self, parameter_s='', cell=None): |
| 206 | """Run a statement through the python code profiler. |
| 207 | |
| 208 | **Usage, in line mode**:: |
| 209 | |
| 210 | %prun [options] statement |
| 211 | |
| 212 | **Usage, in cell mode**:: |
| 213 | |
| 214 | %%prun [options] [statement] |
| 215 | code... |
| 216 | code... |
| 217 | |
| 218 | In cell mode, the additional code lines are appended to the (possibly |
| 219 | empty) statement in the first line. Cell mode allows you to easily |
| 220 | profile multiline blocks without having to put them in a separate |
| 221 | function. |
| 222 | |
| 223 | The given statement (which doesn't require quote marks) is run via the |
| 224 | python profiler in a manner similar to the profile.run() function. |
| 225 | Namespaces are internally managed to work correctly; profile.run |
| 226 | cannot be used in IPython because it makes certain assumptions about |
| 227 | namespaces which do not hold under IPython. |
| 228 | |
| 229 | Options: |
| 230 | |
| 231 | -l <limit> |
| 232 | you can place restrictions on what or how much of the |
| 233 | profile gets printed. The limit value can be: |
| 234 | |
| 235 | * A string: only information for function names containing this string |
| 236 | is printed. |
| 237 | |
| 238 | * An integer: only these many lines are printed. |
| 239 | |
| 240 | * A float (between 0 and 1): this fraction of the report is printed |
| 241 | (for example, use a limit of 0.4 to see the topmost 40% only). |
| 242 | |
| 243 | You can combine several limits with repeated use of the option. For |
| 244 | example, ``-l __init__ -l 5`` will print only the topmost 5 lines of |
| 245 | information about class constructors. |
| 246 | |
| 247 | -r |
| 248 | return the pstats.Stats object generated by the profiling. This |
| 249 | object has all the information about the profile in it, and you can |
| 250 | later use it for further analysis or in other functions. |
| 251 | |
| 252 | -s <key> |
| 253 | sort profile by given key. You can provide more than one key |
| 254 | by using the option several times: '-s key1 -s key2 -s key3...'. The |
| 255 | default sorting key is 'time'. |
| 256 | |
| 257 | The following is copied verbatim from the profile documentation |
| 258 | referenced below: |
| 259 | |
| 260 | When more than one key is provided, additional keys are used as |
| 261 | secondary criteria when the there is equality in all keys selected |
| 262 | before them. |
nothing calls this directly
no test coverage detected