Skip to content

Commit

Permalink
Merge pull request #3 from publons/noissue_changes_from_user_suggestions
Browse files Browse the repository at this point in the history
Removed redundant README and removed library
  • Loading branch information
cr0mbly authored Nov 26, 2019
2 parents 4b8244b + c4bab43 commit 0fd4b4a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 122 deletions.
106 changes: 0 additions & 106 deletions README.md

This file was deleted.

20 changes: 13 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Flame analyzer
=================

.. image:: https://travis-ci.com/publons/flame-analyzer.svg?branch=master
:target: https://travis-ci.com/publons/flame-analyzer

This package is an often used part of our debug environment at Publons.
It helps benchmark and explain inefficiencies in pieces of code as well as
our dependencies on different service response times.
Expand All @@ -23,7 +26,8 @@ Examples
--------

Saving a Flame graph to an SVG can be done with the following benchmarking
code::

.. code-block:: python
from flame_analyzer import FileFlame
Expand All @@ -32,7 +36,9 @@ code::
# Some expensive piece of code.
[len(u.email) for u in User.objects.all()]
Or directly to the IPython notebook::
Or directly to the IPython notebook

.. code-block:: python
from flame_analyzer import InlineFlame
Expand All @@ -41,9 +47,9 @@ Or directly to the IPython notebook::
# Some expensive piece of code.
[len(u.email) for u in User.objects.all()]
You can also optionally configure the width by adding the width kwarg


You can also optionally configure the width by adding the width kwarg::
.. code-block:: python
with FileFlame(
'./file_flame_test.svg', flame_width=1200,
Expand All @@ -60,7 +66,9 @@ By default both IPython and Django are optional imports meaning you can install
this library and use it in the terminal to debug your app code without them
installed. Support can be added for other Database frameworks or if your
wanting to hook into the context enter/exit methods by creating your own hooks
and adding to the output flame type your wanting for example:::
and adding to the output flame type your wanting for example

.. code-block:: python
from flame_analyzer import InlineFlame
Expand All @@ -83,8 +91,6 @@ and adding to the output flame type your wanting for example:::
class CustomInlineFlame(InlineFlame):
hook_classes = (CustomHook,)


with CustomInlineFlame(flame_width=500):
total_email_length = 0
for u in User.objects.all():
Expand Down
6 changes: 2 additions & 4 deletions flame_analyzer/hooks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from datetime import datetime

from humanize import naturaldelta

"""
Hooks allow the flamegraph functionality to be extended in a framework specific
way. By default TimeTakenHook is set but depending on your stack you can further
Expand All @@ -18,11 +16,11 @@ def before(self):
self.started = datetime.now()

def after(self):
self.time_taken = naturaldelta(datetime.now() - self.started)
self.time_taken = str(datetime.now() - self.started)

def modify_flame_options(self, flame_options):
title = flame_options.get('title', '')
title += 'Excecuted context in {}. '.format(self.time_taken)
title += 'Executed context in {}. '.format(self.time_taken)
flame_options['title'] = title

return flame_options
Expand Down
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='flame-analyzer',
version='0.1.4',
version='0.1.5',
packages=find_packages(
include=['flame_analyzer'], exclude=('tests')
),
Expand All @@ -20,9 +20,6 @@
'A small Django and IPython compatible application for benchmarking '
'database and IO heavy work.'
),
install_requires=[
'humanize',
],
url='https://github.com/publons/flame-analyzer',
author='Matthew Betts, Aidan Houlihan',
author_email='[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_time_is_tracked(self):

modified_options = self.hook.modify_flame_options({})
self.assertEqual(
'Excecuted context in a second. ',
'Executed context in {}. '.format(self.hook.time_taken),
modified_options['title'],
)

Expand Down

0 comments on commit 0fd4b4a

Please sign in to comment.