This repository has been archived by the owner on Feb 14, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix connection handling in the RabbitMQ handler, update the HeapReque…
…stHandler and add a HeapRequestHandler output report tool
- Loading branch information
Gavin M. Roy
committed
Oct 23, 2012
1 parent
26a4543
commit eeeb56c
Showing
5 changed files
with
112 additions
and
58 deletions.
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
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
__version__ = '0.9.2' | ||
__version__ = '0.9.3' | ||
__desc__ = 'Tinman adds a little more stack to Tornado' |
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
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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python | ||
"""Will generate a plaintext report from the JSON document created | ||
by the HeapyRequestHandler. | ||
Usage: tinman-heap-report file.json | ||
""" | ||
import json | ||
import os | ||
import sys | ||
|
||
|
||
def print_row(row, depth): | ||
prefix = ''.join([' ' for offset in range(0, depth * 4)]) | ||
item = '%s - %s' % (prefix, row['item']) | ||
parts = [item.ljust(80), | ||
('%(value)s' % (row['count'])).rjust(10), | ||
(' %(percent)s%%' % (row['count'])).rjust(7), | ||
('%(value)s' % (row['size'])).rjust(10), | ||
(' %(percent)s%%' % (row['size'])).rjust(7)] | ||
print ''.join(parts) | ||
|
||
|
||
def main(): | ||
if len(sys.argv) == 1 or not (os.path.exists(sys.argv[1]) and | ||
os.path.isfile(sys.argv[1])): | ||
print 'Usage: tinman-heap-report heap-file.json\n' | ||
sys.exit(-1) | ||
with open(sys.argv[1], "r") as handle: | ||
report = json.load(handle) | ||
print ''.join(['Item'.ljust(80), 'Count'.rjust(17), 'Size'.rjust(17)]) | ||
print ''.join(['-' for position in xrange(0, 114)]) | ||
for row in report['rows']: | ||
print_row(row, 0) | ||
for child in row['referrers']['rows']: | ||
print_row(child, 1) | ||
for grandchild in child['referrers']['rows']: | ||
print_row(grandchild, 2) | ||
|
||
if __name__ == '__main__': | ||
main() |