Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements #18

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
71fc613
Setup Travis
jstasiak Dec 12, 2013
dde519e
Refactor DisplayFormat
jstasiak Dec 12, 2013
68a1678
Make stop() fail if called when profiling is not on
jstasiak Dec 12, 2013
bf8cbb8
Refactor CodeKey
jstasiak Dec 12, 2013
906bac6
Add some docstrings
jstasiak Dec 12, 2013
61f9881
Fix formatting
jstasiak Dec 12, 2013
28ae95c
Refactor some code into ProfileState methods
jstasiak Dec 12, 2013
cba2b52
Format file paths
jstasiak Dec 12, 2013
5774f70
Refactor DisplayFormat a bit more
jstasiak Dec 12, 2013
3b32467
Run flake8 on the code as part of test suite
jstasiak Apr 8, 2014
c4d41f3
Use six to provide iteritems/itervalues
jstasiak Apr 8, 2014
4ec4e99
Clean up a bit
jstasiak Oct 8, 2014
5108cbc
Make source compatible with Python 3 without 2to3
jstasiak Oct 8, 2014
7347069
Prepare for PyPI release
jstasiak Oct 8, 2014
7392be8
Mark package as not zip_safe
jstasiak Oct 8, 2014
c097127
Generate universal wheels
jstasiak Oct 8, 2014
355fb54
Tune metadata
jstasiak Oct 8, 2014
ef244f7
Fix typo
jstasiak Oct 8, 2014
bc3368e
Add ability to run statprof as a module.
nvie Sep 4, 2013
42f24b9
Expand the script's path first.
nvie Sep 4, 2013
fd6a914
Make sure everything is still importable in the target script.
nvie Sep 4, 2013
ef64bcc
Use runpy, allows python -mstatprof -mmodule_name.
anntzer Nov 13, 2013
85366eb
Python 3 compat: Use six.exec_ instead of execfile
jstasiak Oct 8, 2014
d0f7233
Update README.rst
jstasiak Oct 8, 2014
c099c21
Bump version to 0.2.0c2
jstasiak Oct 8, 2014
6825291
Test with Python 3.4
jstasiak Oct 8, 2014
81e51df
Set __name__ correctly when executing files
jstasiak Oct 9, 2014
59f0999
Support python -mstatprof -c cmd; use runpy.run_path.
anntzer Dec 16, 2014
443eaf3
Release version 0.2.0
jstasiak Apr 17, 2015
48b0942
Optionally allow the profile display to be sorted by cumulative time
Jul 16, 2015
6df6fe8
Fix line length and whitespace issues indicated by flake8
Jul 17, 2015
91daa05
Bump up version for pypi package
Jul 17, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions .travis.yml
@@ -0,0 +1,14 @@
language: python
python:
- "2.6"
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "pypy"
install:
- pip install "mock>=1.0.1" "nose>=1.3.0" flake8
- python setup.py clean build --build-base="build/$TRAVIS_PYTHON_VERSION" install
script:
- nosetests -v --no-path-adjustment
- flake8 --max-line-length=110 *.py
5 changes: 4 additions & 1 deletion AUTHORS
@@ -1,5 +1,6 @@
statprof was originally written by Andy Wingo, and later ported to modern
Python by Alex Frazer. It's now maintained by Bryan O'Sullivan.
Python by Alex Frazer. Used to be maintained by Bryan O'Sullivan, this fork
is maintained by Smarkets.

And here is an list of people who have submitted patches, reported bugs, and
generally made statprof that much better:
Expand All @@ -9,3 +10,5 @@ generally made statprof that much better:
* Bryan O'Sullivan <bos@serpentine.com>
* Rob Browning <rlb at defaultvalue dot org>
* Timothée Peignier <tim at tryphon dot org>
* Vincent Driessen <vincent@3rdcloud.com>
* Antony Lee
80 changes: 65 additions & 15 deletions README.rst
@@ -1,6 +1,12 @@
statprof - statistical profiling for Python
===========================================

.. image:: https://travis-ci.org/smarkets/statprof.svg?branch=master
:target: https://travis-ci.org/smarkets/statprof

.. image:: https://img.shields.io/pypi/v/statprof-smarkets.svg
:target: https://pypi.python.org/pypi/statprof-smarkets

This package provides a simple statistical profiler for Python.

Python's default profiler has been ``lsprof`` for several years. This is
Expand All @@ -20,27 +26,56 @@ accurately.
implementation and portability notes below for details.


How to get it
-------------

Use pip!

::

pip install statprof-smarkets

Warning: it uses ``statprof`` as Python module name so this will conflict with
original statprof installation if present.

GitHub project page: https://github.com/smarkets/statprof

PyPI page: https://pypi.python.org/pypi/statprof-smarkets

Basic usage
-----------

It's easy to get started with ``statprof``: ::
It's easy to get started with ``statprof``:

.. code-block:: python

import statprof

statprof.start()
try:
my_questionable_function()
try:
my_questionable_function()
finally:
statprof.stop()
statprof.display()
statprof.stop()
statprof.display()

Or with a contextmanager:

Or with a contextmanager : ::
.. code-block:: python

import statprof

with statprof.profile():
my_questionable_function()

Or from command line:

::

$ python -m statprof script.py
# or
$ python -m statprof -m script
# or (this may depend on bash because http://www.gnu.org/software/bash/manual/bashref.html#ANSI_002dC-Quoting)
$ python -m statprof -c "import hashlib"$'\n'"for i in range(10000): hashlib.md5(str(i)).hexdigest()"

For more comprehensive help, run ``pydoc statprof``.

Expand Down Expand Up @@ -74,24 +109,39 @@ block.
The profiler also tries (as much as possible) to avoid counting or
timing its own code.

Changelog
---------

0.2.0
`````

* forked
* refactored
* added configurable display format (displays full paths by default now)
* ability to run whole scripts under statprof from command line (thanks to
`Vincent Driessen <https://github.com/nvie>`_ and
`Antony Lee <https://github.com/anntzer>`_
* added support for ``python -mstatprof -c cmd`` invocation (thanks to
`Antony Lee <https://github.com/anntzer>`_)

History
-------

This package was originally
written and released by `Andy Wingo <http://wingolog.org/archives/2005/10/28/profiling>`_.
It was ported to modern Python by Alex Frazer, and posted to github by
Jeff Muizelaar. The current maintainer is `Bryan O'Sullivan <bos@serpentine.com>`_.
This package was originally written and released by
`Andy Wingo <http://wingolog.org/archives/2005/10/28/profiling>`_.
It was ported to modern Python by Alex Frazer, and posted to GitHub by
Jeff Muizelaar. Maintained by `Bryan O'Sullivan <bos@serpentine.com>`_, was forked by
Smarkets due to package not being maintaned anymore.


Reporting bugs, contributing patches
------------------------------------

The current maintainer of this package is `Bryan O'Sullivan <bos@serpentine.com>`_.

Please report bugs using the `github issue tracker <https://github.com/bos/statprof.py/issues>`_.
Please report bugs using the `GitHub issue tracker <https://github.com/smarkets/statprof/issues>`_.

If you'd like to contribute patches, please do - the source is on
github, so please just issue a pull request. ::
GitHub, so please just issue a pull request.

::

$ git clone git://github.com/bos/statprof.py
$ git clone git://github.com/smarkets/statprof
2 changes: 2 additions & 0 deletions setup.cfg
@@ -0,0 +1,2 @@
[wheel]
universal = True
27 changes: 14 additions & 13 deletions setup.py
@@ -1,24 +1,22 @@
#!/usr/bin/env python

import os, sys
import os

from setuptools import setup


def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()

extra = {}
if sys.version_info >= (3,):
extra['use_2to3'] = True

setup(
name="statprof",
version="0.1.3",
author="Bryan O'Sullivan",
author_email="bos@serpentine.com",
name="statprof-smarkets",
version="1.0.0",
author="Smarkets",
author_email="support@smarkets.com",
description="Statistical profiling for Python",
license=read('LICENSE'),
keywords="profiling",
url="http://packages.python.org/statprof",
license='LGPL 2, see LICENSE file',
keywords=["profiling", "statistical profiling", "statprof"],
url="https://github.com/smarkets/statprof",
py_modules=['statprof'],
long_description=read('README.rst'),
classifiers=[
Expand All @@ -29,5 +27,8 @@ def read(fname):
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
],
**extra
install_requires=[
'six>=1.5.0',
],
zip_safe=False,
)