PageRenderTime 36ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/templates/admin/memdump.mako

https://bitbucket.org/cistrome/cistrome-harvard/
Mako | 76 lines | 69 code | 7 blank | 0 comment | 4 complexity | 96fb2900e6234661643e4b3665b84e3a MD5 | raw file
  1. <%inherit file="/base.mako"/>
  2. <%namespace file="/message.mako" import="render_msg" />
  3. <%def name="title()">Memory Profiling</%def>
  4. <%
  5. import re
  6. from xml.sax.saxutils import escape, unescape
  7. %>
  8. <style type="text/css">
  9. a.breadcrumb:link,
  10. a.breadcrumb:visited,
  11. a.breadcrumb:active {
  12. text-decoration: none;
  13. }
  14. a.breadcrumb:hover {
  15. text-decoration: underline;
  16. }
  17. </style>
  18. <h2>Memory Profiling</h2>
  19. <ul class="manage-table-actions">
  20. <li><a class="action-button" href="${h.url_for( controller='admin', action='memdump', dump=True )}">Dump memory (warning: hangs server!)</a></li>
  21. <li><a class="action-button" href="${h.url_for( controller='admin', action='memdump', setref=True )}">Set reference point</a></li>
  22. </ul>
  23. <%def name="htmlize( heap )">
  24. <%
  25. s = escape( str( heap ) )
  26. new_s = ""
  27. id_re = re.compile('^(\s+)([0-9]+)')
  28. for line in s.split( '\n' ):
  29. try:
  30. id = id_re.search( line ).group( 2 )
  31. except:
  32. id = None
  33. new_s += re.sub( id_re, r'\1<a href="' + h.url_for( controller='admin', action='memdump', ids=ids, sorts=sorts, new_id=id ) + r'">\2</a>', line )
  34. if id and heap[int(id)].count == 1:
  35. new_s += " <a href='%s'>theone</a>\n" % h.url_for( controller='admin', action='memdump', ids=ids, sorts=sorts, new_id=id, theone=True )
  36. else:
  37. new_s += "\n"
  38. return new_s
  39. %>
  40. </%def>
  41. %if message:
  42. ${render_msg( message, status )}
  43. %endif
  44. %if heap is None:
  45. No memory dump available. Click "Dump memory" to create one.
  46. %else:
  47. <pre>
  48. <br/>
  49. You are here: ${breadcrumb}<br/>
  50. %if breadcrumb.endswith( 'theone' ):
  51. ${heap}
  52. %else:
  53. <nobr>
  54. Sort:
  55. <a href="${h.url_for( controller='admin', action='memdump', ids=ids, sorts=sorts, new_sort='Class')}">Class</a> |
  56. <a href="${h.url_for( controller='admin', action='memdump', ids=ids, sorts=sorts, new_sort='Clodo' )}">Clodo</a> |
  57. <a href="${h.url_for( controller='admin', action='memdump', ids=ids, sorts=sorts, new_sort='Id' )}">Id</a> |
  58. <a href="${h.url_for( controller='admin', action='memdump', ids=ids, sorts=sorts, new_sort='Idset' )}">Idset</a> |
  59. <a href="${h.url_for( controller='admin', action='memdump', ids=ids, sorts=sorts, new_sort='Module' )}">Module</a> |
  60. <a href="${h.url_for( controller='admin', action='memdump', ids=ids, sorts=sorts, new_sort='Unity' )}">Unity</a> |
  61. <a href="${h.url_for( controller='admin', action='memdump', ids=ids, sorts=sorts, new_sort='Rcs' )}">Rcs</a> |
  62. <a href="${h.url_for( controller='admin', action='memdump', ids=ids, sorts=sorts, new_sort='Size' )}">Size</a> |
  63. <a href="${h.url_for( controller='admin', action='memdump', ids=ids, sorts=sorts, new_sort='Type' )}">Type</a> |
  64. <a href="${h.url_for( controller='admin', action='memdump', ids=ids, sorts=sorts, new_sort='Via' )}">Via</a>
  65. </nobr>
  66. ${htmlize( heap )}
  67. %endif
  68. </pre>
  69. %endif