memprof
Memory profiler using ICE logging of manual memory allocations.
- alias YAMLNode;
Readability aliases
- struct MemProf;
-
Contains all profiling functionality. Might be split into multiple classes/functions if needed.
- this(string fileName);
Construct MemProf loading memory log from specified file.
- this(ref File file);
Construct MemProf loading memory log from specified file object (e.g. stdin).
- @property ref YAMLNode memoryLog();
Get the memory log loaded from YAML.
- NamedNode[] allocationDistribution(T, bool logarithmic = false)(ref YAMLNode allocations, string property, T linearCategorySize);
Allocation distribution in intervals, useful for e.g. allocation sizes.
Categorizes allocations based on specified property; returns an array of named nodes where name is composed of name of the property and the interval containing its value, and node is a sequence of all allocations where the value is in the interval.
Parameters:
Only makes sense for numeric properties.Returns:allocations Allocations to distribute. property Property to distribute according to. linearCategorySize When logarithmic is false, this is the size of the intervals used. logarithmic Should the intervals be based on powers of two? (0-1, 1-2, 2-4, 4-8 ... 256-512 ...) Useful for allocation sizes. Categories (allocation sequences) with names corresponding to intervals containing their values of specified property.- NamedNode[] allocationDistribution(T)(ref YAMLNode allocations, string property);
Non-interval allocation distribution, useful for e.g. files and types.
Categorizes allocations based on specified property; returns an array of named nodes where name is composed of name of the property and its value, and node is a sequence of all allocations with that value of specified property.
Parameters:Returns:allocations Allocations to distribute. property Property to distribute according to. Categories (allocation sequences) with names corresponding to values of specified property.- YAMLNode aggregate(T)(ref YAMLNode allocations, T delegate(ref YAMLNode) evaluate, Flag!("average") average = No.average);
Aggregate allocations into a value (e.g. total bytes).
Will sum the value returned for each allocation by evaluate(), and optionally average it.
Parameters:Returns:A YAML scalar storing the aggregated value.- static Node[] filterAllocations(ref YAMLNode allocations, Filter predicate);
Filter a sequence of YAML allocations to only those which satisfy predicate.
Parameters:Returns:YAMLNode allocations YAML sequence of allocations to process. Filter predicate Allocations for which this function returns true are kept; those for which it returns false are removed. Filtered YAML sequence containing only allocations that satisfy predicate.- static Node[] topAllocations(ref YAMLNode allocations, bool delegate(ref Node, ref Node) less, const ulong topCount);
Get the topCount greatest allocations sorted by specified less function.
Parameters:Returns:YAMLNode allocations Allocations to process. bool delegate(ref Node, ref Node) less Comparison function to sort the allocations. ulong topCount Number of allocations to get. An array of topCount greatest allocations.- T[] listValues(T)(ref YAMLNode allocations, string property);
Lists all existing values of specified allocation property.
E.g. all files, all byte sizes, etc. .
Parameters:Returns:allocations A sequence of allocations to list values for. property Allocation property to list values of. Array of all values of specified property.- T max(T)(ref YAMLNode allocations, T delegate(ref YAMLNode) evaluate);
Get the maximum value returned by evaluate() for an allocation.
This computes evaluate(allocation) for each allocation and returns the maximum.
Parameters:Returns:allocations YAML sequence of allocations to process. evaluate Function to evaluate each allocation with. Maximum value of evaluate(allocation) from given sequence of allocations.
- Tuple!(T,T)[] parseRanges(T)(string raw);
Parse a string of ranges in format "a-b,c-d,e".
Parameters:Returns:raw Raw string before parsing. Parsed ranges.Throws:ConvException on a number parsing error. MemProfCLIException on an invalid range.- void processOption(string arg, void delegate(string, string[]) process);
Process a command line option (argument starting with --).
Parameters:Throws:string arg Argument to process. void delegate(string, string[]) process Function to process the option. Takes the option and its arguments. MemProfCLIException if arg is not an option, and anything process() throws.- void help();
- class MemProfCLIException: object.Exception;
Exception thrown at CLI errors.
- struct MemProfCLI;
Parses MemProf CLI commands, composes them into an action to execute, and executes it.
- this(string[] cliArgs);
Construct a MemProfCLI with specified command-line arguments and parse them.
- void translateAliases(ref string[] args);
Cheap hack to avoid implementing "total" and "average" commands with logic duplicated from "distribution".
We simply translate the command line args.
- void execute();
Execute the action specified by command line arguments.
- void main(string[] args);
Program entry point.