memprof - ICE 0.1 API documentation

ICE 0.1 API documentation

# memprof

Memory profiler using ICE logging of manual memory allocations.

alias YAMLNode;

  Readability aliases

struct MemProf;

  Main MemProf object.

  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.
    Only makes sense for numeric properties.

    Parameters:

    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.

    Returns:
    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:

    allocations | Allocations to distribute.
    property | Property to distribute according to.

    Returns:
    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:

    allocations | Allocations to aggregate.
    evaluate | Evaluates an allocations and returns a partial value to aggregate (e.g. size of an allocation in bytes).
    average | If true, an average is returned. Otherwise, a sum is returned.

    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:

    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.

    Returns:
    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:

    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.

    Returns:
    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:

    allocations | A sequence of allocations to list values for.
    property | Allocation property to list values of.

    Returns:
    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:

    allocations | YAML sequence of allocations to process.
    evaluate | Function to evaluate each allocation with.

    Returns:
    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:

  raw | Raw string before parsing.

  Returns:
  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:

  string arg | Argument to process.
  void delegate(string, string[]) process | Function to process the option. Takes the option and its arguments.

  Throws:
  MemProfCLIException if arg is not an option, and anything process() throws.
void help();

  Print help information.

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.

Copyright © Ferdinand Majerech 2011. | Page generated by AutoDDoc and Ddoc.