Provide saving, loading and presenting gathered ClassTracker statistics.
Presents the memory statistics gathered by a ClassTracker based on user preferences.
Initialize the data log structures either from a ClassTracker instance (argument tracker) or a previously dumped file (argument filename).
Parameters: |
|
---|
Load the data from a dump file. The argument fdump can be either a filename or an open file object that requires read access.
Sort the tracked objects according to the supplied criteria. The argument is a string identifying the basis of a sort (example: ‘size’ or ‘classname’). When more than one key is provided, then additional keys are used as secondary criteria when there is equality in all keys selected before them. For example, sort_stats('name', 'size') will sort all the entries according to their class name, and resolve all ties (identical class names) by sorting by size. The criteria are fields in the tracked object instances. Results are stored in the self.sorted list which is used by Stats.print_stats() and other methods. The fields available for sorting are:
- ‘classname’
- the name with which the class was registered
- ‘name’
- the classname
- ‘birth’
- creation timestamp
- ‘death’
- destruction timestamp
- ‘size’
- the maximum measured size of the object
- ‘tsize’
- the measured size during the largest snapshot
- ‘repr’
- string representation of the object
Note that sorts on size are in descending order (placing most memory consuming items first), whereas name, repr, and creation time searches are in ascending order (alphabetical).
The function returns self to allow calling functions on the result:
stats.sort_stats('size').reverse_order().print_stats()
Dump the logged data to a file. The argument file can be either a filename or an open file object that requires write access. close controls if the file is closed before leaving this method (the default behaviour).
Reverse the order of the tracked instance index self.sorted.
Presentation layer for Stats to be used in text-based consoles.
Initialize the data log structures either from a ClassTracker instance (argument tracker) or a previously dumped file (argument filename).
Parameters: |
|
---|
Write tracked objects to stdout. The output can be filtered and pruned. Only objects are printed whose classname contain the substring supplied by the clsname argument. The output can be pruned by passing a limit value.
Parameters: |
|
---|
Print per-class summary for each snapshot.
Output the ClassTracker statistics as HTML pages and graphs.
Initialize the data log structures either from a ClassTracker instance (argument tracker) or a previously dumped file (argument filename).
Parameters: |
|
---|
Create HTML page fname and additional files in a directory derived from fname.