diff --git a/screenshots/10.png b/screenshots/10.png index e3bf7673..6919692f 100644 Binary files a/screenshots/10.png and b/screenshots/10.png differ diff --git a/silk/templates/silk/profile_detail.html b/silk/templates/silk/profile_detail.html index 0cc26546..9badaab1 100644 --- a/silk/templates/silk/profile_detail.html +++ b/silk/templates/silk/profile_detail.html @@ -7,7 +7,6 @@ {% block js %} - {{ block.super }} {% endblock %} @@ -68,26 +67,6 @@ svg { display: block; } - - .file-path { - font-size: 13px; - } - - .file-path>a { - color: black; - } - - .file-path>a:hover { - color: #9dd0ff; - } - - .file-path>a:active { - color: #594F4F; - } - - #pyprofile-table { - margin-top: 25px; - } {% endblock %} @@ -150,7 +129,7 @@ function (response) { var svg = '#graph-div'; $(svg).html(Viz(response.dot)); - $(svg + ' svg').attr('width', 960).attr('height', 480); + $(svg + ' svg').attr('width', 960).attr('height', 600); svgPanZoom(svg + ' svg', { controlIconsEnabled: true }); } ); @@ -164,38 +143,13 @@
Python Profiler
-
- Below is a dump from the cPython profiler. - {% if silk_request.prof_file %} - Click here to download profile. - {% endif %} + The below is a dump from the cPython profiler.
- - - {% for row in silk_request.profile_table %} - - {% for column in row %} - {% if forloop.parentloop.counter0 %} - - {% else %} - - {% endif %} - {% endfor %} - - {% endfor %} -
- {% if forloop.counter0 == file_column %} -
- {{ column }} -
- {% if forloop.parentloop.counter0 == pos %} - {% code pyprofile_code pyprofile_actual_line %} - {% endif %} - {% else %} - {{ column }} - {% endif %} -
{{ column }}
+ {% if silk_request.prof_file %} + Click here to download profile. + {% endif %} +
{{ silk_request.pyprofile }}
{% endif %} diff --git a/silk/views/profile_dot.py b/silk/views/profile_dot.py index d40a83de..b9b91c6d 100644 --- a/silk/views/profile_dot.py +++ b/silk/views/profile_dot.py @@ -10,12 +10,22 @@ from django.utils.decorators import method_decorator from django.views.generic import View from django.http import HttpResponse -from gprof2dot import DotWriter, PstatsParser, Profile, TEMPERATURE_COLORMAP +from gprof2dot import DotWriter, PstatsParser, Theme # silk from silk.auth import login_possibly_required, permissions_possibly_required from silk.models import Request +COLOR_MAP = Theme( + mincolor=(0.18, 0.51, 0.53), + maxcolor=(0.03, 0.49, 0.50), + gamma=1.5, + fontname='FiraSans', + minfontsize=6.0, + maxfontsize=6.0, +) + + @contextmanager def _temp_file_from_file_field(source): """ @@ -48,21 +58,17 @@ def _create_dot(profile, cutoff): profile.prune(node_cutoff, edge_cutoff, False) with closing(StringIO()) as fp: - DotWriter(fp).graph(profile, TEMPERATURE_COLORMAP) + DotWriter(fp).graph(profile, COLOR_MAP) return fp.getvalue() -def _get_dot(request_id, cutoff): - silk_request = get_object_or_404(Request, pk=request_id, prof_file__isnull=False) - profile = _create_profile(silk_request.prof_file) - result = dict(dot=_create_dot(profile, cutoff)) - return HttpResponse(json.dumps(result).encode('utf-8'), content_type='application/json') - - class ProfileDotView(View): @method_decorator(login_possibly_required) @method_decorator(permissions_possibly_required) def get(self, request, request_id): + silk_request = get_object_or_404(Request, pk=request_id, prof_file__isnull=False) cutoff = float(request.GET.get('cutoff', '') or 5) - return _get_dot(request_id, cutoff) + profile = _create_profile(silk_request.prof_file) + result = dict(dot=_create_dot(profile, cutoff)) + return HttpResponse(json.dumps(result).encode('utf-8'), content_type='application/json')