<commit_before>spyder_line_profiler
====================

Description
-----------

This is a plugin to run the python `line profiler <http://pythonhosted.org/line_profiler/>`_ from within the `spyder <https://code.google.com/p/spyderlib/>`_ editor.

The code is an adaptation of the profiler plugin integrated in `spyder <https://code.google.com/p/spyderlib/>`_.

Install instructions
--------------------

Put the files ``p_lineprofiler.py`` and ``widgets/lineprofilergui.py`` in the directory ``spyderplugins/`` from the spyder installation.

For example on Linux this should be ``/usr/lib/python2.7/dist-packages/spyderplugins/`` or equivalent.

The line_profiler module and the kernprof.py script have to be installed and acessible on the system. See the `official website <http://pythonhosted.org/line_profiler/>`_ for instructions.

Usage
-----

Add a ``@profile`` decorator to the functions that you wish to profile then press Shift+F10 (default) to run the line profiler on the current script or go to ``Execution > Profile line by line``.

The results will be shown in a dockwidget, grouped by function. Lines with a stronger color take more time to run.

Screenshot
----------

.. image:: spyder_line_profiler.png<commit_msg>Typo and note for python2 only<commit_after>spyder_line_profiler
====================

Description
-----------

This is a plugin to run the python `line profiler <http://pythonhosted.org/line_profiler/>`_ from within the `spyder <https://code.google.com/p/spyderlib/>`_ editor.

The code is an adaptation of the profiler plugin integrated in `spyder <https://code.google.com/p/spyderlib/>`_.

Install instructions
--------------------

Put the files ``p_lineprofiler.py`` and ``widgets/lineprofilergui.py`` in the directory ``spyderplugins/`` from the spyder installation.

For example on Linux this should be ``/usr/lib/python2.7/dist-packages/spyderplugins/`` or equivalent.

The line_profiler module and the kernprof.py script have to be installed and accessible on the system. See the `official website <http://pythonhosted.org/line_profiler/>`_ for instructions. Note that the official line_profiler runs on python2 only.

Usage
-----

Add a ``@profile`` decorator to the functions that you wish to profile then press Shift+F10 (default) to run the line profiler on the current script or go to ``Execution > Profile line by line``.

The results will be shown in a dockwidget, grouped by function. Lines with a stronger color take more time to run.

Screenshot
----------

.. image:: spyder_line_profiler.png
{'fraction_non_alphanumeric': 0.13388299960738123, 'fraction_numerical': 0.0039261876717707105, 'mean_word_length': 3.9, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6130568', 'n_tokens_mistral': 738, 'n_tokens_neox': 732, 'n_words': 291}