Skip to content
Snippets Groups Projects
Commit cc0c3c6e authored by Pierre Augier's avatar Pierre Augier
Browse files

Improve analyze_stats

parent a7402a26
No related branches found
No related tags found
1 merge request!162Topic/default/doc phaseshift
Pipeline #8792 passed
......@@ -331,7 +331,9 @@
_kinds = ("fft_as", "pythran", ".pyx", ".py", "built-in", "numpy")
def analyze_stats(path, nb_dim=2, plot=False, threshold_long_function=0.01):
def analyze_stats(
path, nb_dim=2, plot=False, threshold_long_function=0.01, verbose=True
):
"""Print analysis of profiling result of a 2D solver.
Parameters
......@@ -341,7 +343,8 @@
"""
stats = pstats.Stats(str(path))
stats.sort_stats("time").print_stats(20)
if verbose:
stats.sort_stats("time").print_stats(20)
if nb_dim not in (2, 3):
raise NotImplementedError
......@@ -404,6 +407,13 @@
time=time, percentage=100 * time / total_time, kind=k
)
if plot:
plot_pie(times, long_functions)
plt.show()
if not verbose:
return times, long_functions
print(
"\nlong_functions (more than {} % of total time):".format(
100 * threshold_long_function
......@@ -426,9 +436,9 @@
t = times[k]
if t > 0:
print(
"time {:10s}: {:5.03f} % ({:4.02f} s)".format(
"time {:10s}: {:7.03f} % ({:4.02f} s)".format(
k, t / total_time * 100, t
)
)
print(
......@@ -430,10 +440,10 @@
k, t / total_time * 100, t
)
)
print(
"-" * 24
+ "\n{:15s} {:5.02f} %".format(
"-" * 26
+ "\n{:15s} {:7.03f} %".format(
"", sum([t for t in times.values()]) / total_time * 100
)
)
......@@ -442,6 +452,6 @@
time_in_not_py = sum([t for t in times.values()])
print(
"In not Python functions:\n{:15s}".format("")
+ " {:5.02f} %".format(time_in_not_py / total_time * 100)
+ " {:7.03f} %".format(time_in_not_py / total_time * 100)
)
......@@ -446,7 +456,3 @@
)
if plot:
plot_pie(times, long_functions)
plt.show()
return times, long_functions
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment