Giter VIP home page Giter VIP logo

nose-cprof's Introduction

nose-cprof

A plugin to use cProfile to profile nosetests, rather than the built-in Hotshot profiler.

Profiling tests can help track down sources of performance issues in code, especially if a synthetic test can be created to focus on the area of concern.

The output generated by this plugin can easily be browsed using pstats_viewer, or any other pstats-compatible viewer.

Getting started

Prerequisites

This is a plugin for nose, so it's useless without that installed.

Installation

pip install nose-cprof

Usage

This plugin adds some new options to nosetests:

--with-cprofile       Enable plugin cProfiler:  Use this plugin to run tests
                      using the cProfile profiler.  [NOSE_WITH_CPROFILE]
--cprofile-stats-file=FILE
                      Output file name; default "stats.dat"
--cprofile-stats-erase
                      Erase previously-collected profiling statistics before
                      run. Without this option, new profiling stats will be
                      merged with the prior contents of the output file.

nose-cprof's People

Contributors

msherry avatar severb avatar vaab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nose-cprof's Issues

Accumulating cProfile stats between runs

I'm looking for a way to accumulate cprofile stats in the output file between runs. In the current code of nose-cprof, by using function cProfile.dump_stats(..), it'll overwrite the current file and as a consequence will not accumulate stats with previous runs.

Here's a link towards the code of dump_stats() that didn't seem to change from 2.7 to 3.6 at least:
https://github.com/python/cpython/blob/master/Lib/cProfile.py#L44-L48

Strangely enough for me, you provide a --cprofile-stats-erase command line argument that allows to erase the file prior to a cprofile run... at first glance, discovering this possibility, I expected then that the stats where actually accumulating in a possibily pre-existing file if we didn't provide this command line argument.

The code to get the accumulation is quick to write and I'm ready to send you a PR, but are you interested in that feature, or if not, could you tell me why you provide --cprofile-stats-erase if you are going to ignore the content of that file anyway ?

Did I miss anything ?

Many thanks for your attention and for writing this nose plugin.

'pip install nose-cprof' fails -- No such file README.md

It looks like README.md might simply be missing from the tar. Here are steps to reproduce and the callstack:

$ pip install nose-cprof

Downloading/unpacking nose-cprof
  Downloading nose-cprof-0.1-2.tar.gz
  Running setup.py egg_info for package nose-cprof
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/tmp/pip-build-user/nose-cprof/setup.py", line 12, in <module>
        with open(os.path.join(PATH_TO_FILE, 'README.md')) as f:
    IOError: [Errno 2] No such file or directory: '/tmp/pip-build-user/nose-cprof/README.md'

And downloading the tar from pypi confirms that README.md is missing:

$ tar -tvf ~/Downloads/nose-cprof-0.1-2.tar.gz

drwxr-xr-x marc/staff        0 2016-09-08 14:05 nose-cprof-0.1-2/
-rw-r--r-- marc/staff       50 2016-09-08 13:36 nose-cprof-0.1-2/MANIFEST.in
drwxr-xr-x marc/staff        0 2016-09-08 14:05 nose-cprof-0.1-2/nose_cprof.egg-info/
-rw-r--r-- marc/staff        1 2016-09-08 14:05 nose-cprof-0.1-2/nose_cprof.egg-info/dependency_links.txt
-rw-r--r-- marc/staff       61 2016-09-08 14:05 nose-cprof-0.1-2/nose_cprof.egg-info/entry_points.txt
-rw-r--r-- marc/staff        1 2016-09-08 13:40 nose-cprof-0.1-2/nose_cprof.egg-info/not-zip-safe
-rw-r--r-- marc/staff     1901 2016-09-08 14:05 nose-cprof-0.1-2/nose_cprof.egg-info/PKG-INFO
-rw-r--r-- marc/staff       13 2016-09-08 14:05 nose-cprof-0.1-2/nose_cprof.egg-info/requires.txt
-rw-r--r-- marc/staff      326 2016-09-08 14:05 nose-cprof-0.1-2/nose_cprof.egg-info/SOURCES.txt
-rw-r--r-- marc/staff       14 2016-09-08 14:05 nose-cprof-0.1-2/nose_cprof.egg-info/top_level.txt
drwxr-xr-x marc/staff        0 2016-09-08 14:05 nose-cprof-0.1-2/nose_cprofile/
-rw-r--r-- marc/staff       78 2016-09-08 13:45 nose-cprof-0.1-2/nose_cprofile/__init__.py
-rw-r--r-- marc/staff     2113 2016-09-08 13:56 nose-cprof-0.1-2/nose_cprofile/nose_cprofile.py
-rw-r--r-- marc/staff     1901 2016-09-08 14:05 nose-cprof-0.1-2/PKG-INFO
-rw-r--r-- marc/staff       59 2016-09-08 14:05 nose-cprof-0.1-2/setup.cfg
-rw-r--r-- marc/staff     1365 2016-09-08 13:58 nose-cprof-0.1-2/setup.py

Update PyPI

Thank you for providing this awesome plugin! Would it be possible to update the package on pypi to include the python3 compat change that was added?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.