-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PR: Show time units in Profiler #3741
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d600bf2
Units on profiler
malliwi88 f3e5032
Merge branch '3.x' of https://github.com/spyder-ide/spyder into fix/p…
malliwi88 7d79e11
repair
malliwi88 5f72d7c
add ccordoba suggestions
malliwi88 8cfca21
remove white spaces
malliwi88 025dc1e
Merge branch '3.x' into fix/profilerUnits
malliwi88 d6e49a7
Trying to adjust the time format to the initial logic in profiler
malliwi88 41a43dd
Trying to adjust the time format to the initial logic in profiler
malliwi88 ba8e736
Merge branch '3.x' into fix/profilerUnits
malliwi88 24b974c
solve errors with hidden units on profiler
malliwi88 5a30a2b
Update with 3.x
ccordoba12 8728d9c
Fix style issues
ccordoba12 a7ca626
Profiler: Change a name of a variable
ccordoba12 d024a3d
Profiler: Simplify format_measures
ccordoba12 ac40728
Profiler: Don't format number of calls to a float
ccordoba12 5ead5b5
Profiler: Change call to str for to_text_string
ccordoba12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -495,27 +495,57 @@ def function_info(self, functionKey): | |
node_type = 'constructor' | ||
file_and_line = '%s : %d' % (filename, line_number) | ||
return filename, line_number, function_name, file_and_line, node_type | ||
|
||
|
||
def format_measure(self, measure): | ||
"""Get format and units for data coming from profiler task.""" | ||
# For number of calls | ||
if isinstance(measure, int): | ||
return to_text_string(measure) | ||
|
||
# For time measurements | ||
if 1.e-9 < measure <= 1.e-6: | ||
measure = u"{0:.2f} ns".format(measure / 1.e-9) | ||
elif 1.e-6 < measure <= 1.e-3: | ||
measure = u"{0:.2f} us".format(measure / 1.e-6) | ||
elif 1.e-3 < measure <= 1: | ||
measure = u"{0:.2f} ms".format(measure / 1.e-3) | ||
elif 1 < measure <= 60: | ||
measure = u"{0:.2f} sec".format(measure) | ||
elif 60 < measure <= 3600: | ||
m, s = divmod(measure, 3600) | ||
if s > 60: | ||
m, s = divmod(measure, 60) | ||
s = to_text_string(s).split(".")[-1] | ||
measure = u"{0:.0f}.{1:.2s} min".format(m, s) | ||
else: | ||
h, m = divmod(measure, 3600) | ||
if m > 60: | ||
m /= 60 | ||
measure = u"{0:.0f}h:{1:.0f}min".format(h, m) | ||
return measure | ||
|
||
def color_string(self, args): | ||
x, format = args | ||
x, fmt = args | ||
diff_str = "" | ||
color = "black" | ||
|
||
if len(x) == 2 and self.compare_file is not None: | ||
difference = x[0] - x[1] | ||
if difference < 0: | ||
diff_str = "".join(['',format[1] % difference]) | ||
diff_str = "".join(['', fmt[1] % self.format_measure(difference)]) | ||
color = "green" | ||
elif difference > 0: | ||
diff_str = "".join(['+',format[1] % difference]) | ||
diff_str = "".join(['+', fmt[1] % self.format_measure(difference)]) | ||
color = "red" | ||
return [format[0] % x[0], [diff_str, color]] | ||
|
||
return [fmt[0] % self.format_measure(x[0]), [diff_str, color]] | ||
|
||
def format_output(self,child_key): | ||
def format_output(self, child_key): | ||
""" Formats the data""" | ||
if True: | ||
data = [x.stats.get(child_key,[0,0,0,0,0]) for x in self.stats1] | ||
return map(self.color_string,zip(list(zip(*data))[1:4], [["%i"]*2, ["%.3f","%.3f"], ["%.3f","%.3f"]])) | ||
data = [x.stats.get(child_key, [0,0,0,0,0]) for x in self.stats1] | ||
format_data = zip(list(zip(*data))[1:4], | ||
[["%s"]*2, ["%s", "%s"], ["%s", "%s"]]) | ||
return (map(self.color_string, format_data)) | ||
|
||
def populate_tree(self, parentItem, children_list): | ||
"""Recursive method to create each item (and associated data) in the tree.""" | ||
|
@@ -527,8 +557,6 @@ def populate_tree(self, parentItem, children_list): | |
((total_calls, total_calls_dif), (loc_time, loc_time_dif), (cum_time, | ||
cum_time_dif)) = self.format_output(child_key) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also this? |
||
|
||
(primcalls, total_calls, loc_time, cum_time, callers | ||
) = self.stats[child_key] | ||
child_item = TreeWidgetItem(parentItem) | ||
self.item_list.append(child_item) | ||
self.set_item_data(child_item, filename, line_number) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was this doing and why did you remove it?