Skip to content

Profiler Initial commit#1

Open
ishanSrt wants to merge 5 commits into
masterfrom
profiler
Open

Profiler Initial commit#1
ishanSrt wants to merge 5 commits into
masterfrom
profiler

Conversation

@ishanSrt
Copy link
Copy Markdown
Owner

No description provided.

@@ -4,15 +4,25 @@
while offering the best possible flexibility.
"""
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file contains unused source code.

Origin: PyUnusedCodeBear, Section: flakes.

The issue can be fixed by applying the following patch:

--- a/tmp/tmp7ip5_d4o/coalib/bearlib/__init__.py
+++ b/tmp/tmp7ip5_d4o/coalib/bearlib/__init__.py
@@ -4,7 +4,6 @@
 while offering the best possible flexibility.
 """
 
-import cProfile
 import logging
 
 from coalib.settings.FunctionMetadata import FunctionMetadata

* Bear.py and __init__.py run PEP8Bear,
  fix line length issues.
* use inline if at multiple places.
* change some function names.
* fix a few bugs and cover all cases.
@ishanSrt ishanSrt force-pushed the profiler branch 2 times, most recently from 2ccf8fa to e432828 Compare April 13, 2018 18:14
Comment thread coalib/bears/Bear.py Outdated
@@ -1,8 +1,15 @@
import cProfile
import inspect
import io
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file contains unused source code.

Origin: PyUnusedCodeBear, Section: flakes.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpl9q8g7jr/coalib/bears/Bear.py
+++ b/tmp/tmpl9q8g7jr/coalib/bears/Bear.py
@@ -3,7 +3,6 @@
 import io
 import itertools
 import pstats
-import sys
 import tempfile
 import traceback
 from functools import partial

* display results using terminaltables in terminal
@ishanSrt ishanSrt force-pushed the profiler branch 2 times, most recently from a95be88 to 592ded2 Compare April 14, 2018 07:20
@ishanSrt ishanSrt added size/M and removed size/S labels Apr 14, 2018
Comment thread coalib/bears/Bear.py
try:
for i, c in enumerate(sentence):
if c == lparen:
nb_brackets += 1
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not use the preferred quotation marks.

Origin: QuotesBear, Section: python.

The issue can be fixed by applying the following patch:

--- a/tmp/tmpi5smk0mf/coalib/bears/Bear.py
+++ b/tmp/tmpi5smk0mf/coalib/bears/Bear.py
@@ -292,7 +292,7 @@
                 elif c == separator and nb_brackets == 0:
                     l.append(i)
                 if nb_brackets < 0:
-                    raise ValueError("Invalid arguments to --profile-bears")
+                    raise ValueError('Invalid arguments to --profile-bears')
             l.append(len(sentence))
             if nb_brackets > 0:
                 raise ValueError("Invalid arguments to --profile-bears")

Comment thread coalib/bears/Bear.py
return([sentence[i:j].strip(separator) for i, j in zip(l, l[1:])])

def pstats_config(self, prof, stream, profile_bears):
flag = 0
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E501 line too long (81 > 80 characters)

Origin: PycodestyleBear (E501), Section: autopep8.

Comment thread coalib/bears/Bear.py
return([sentence[i:j].strip(separator) for i, j in zip(l, l[1:])])

def pstats_config(self, prof, stream, profile_bears):
flag = 0
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is longer than allowed. (81 > 80)

Origin: LineLengthBear, Section: linelength.

Comment thread coalib/bears/Bear.py
return([sentence[i:j].strip(separator) for i, j in zip(final, final[1:])])

def pstats_config(self, prof, stream, profile_bears):
flag = 0
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E501 line too long (81 > 80 characters)

Origin: PycodestyleBear (E501), Section: autopep8.

Comment thread coalib/bears/Bear.py
return([sentence[i:j].strip(separator) for i, j in zip(final, final[1:])])

def pstats_config(self, prof, stream, profile_bears):
flag = 0
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is longer than allowed. (81 > 80)

Origin: LineLengthBear, Section: linelength.

@ishanSrt ishanSrt force-pushed the profiler branch 3 times, most recently from 2aed03a to e939cae Compare April 14, 2018 09:15
@ishanSrt
Copy link
Copy Markdown
Owner Author

ack e939cae
ack 7b15342
ack 3e7762a
ack 763cca8
ack 34c9830

Comment thread coalib/bears/Bear.py
elif str_setting == u'print_callers':
ps.print_callers(*args)
elif str_setting == u'print_callees':
ps.print_callees(*args)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I see that the print_callers() and print_callees() can also work without an argument, will be fixing that soon

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently if not provided with an argument they will generate an error and the profiler will go with the default settings

def _do_nothing(x): return x


def profile_bears_decorator(func):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ishanSrt need your help here, I am failing in understanding this change.

Copy link
Copy Markdown
Owner Author

@ishanSrt ishanSrt May 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am enabling the profiler here so that it doesn't contain the overhead of the function calls from the decorator itself and then actually calling the run method using this additional decorator

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if we want to profile our bear it will add this extra decorator which adds prof.enable() just before calling the run() method 😄

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you will need to do the same for the decorators for linters

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it thanks for the help 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants