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