anchor.diff:  %%% Created : 21 Aug 2014 by  <masse@klarna.com>
   
   %% @doc
  +%% {[Allocator,Instance,Group,Type,Info],Count}
  +%%
  +%% Allocator         -> atom(AllocatorName++"_alloc")
  +%% AllocatorName     -> temp| std| sl| ll| fix| ets| eheap| driver| binary
  +%% Instance          -> integer()
  +%% Group             -> CarrierGroup | CallGroup
  +%% CarrierGroup      -> sbcs | mbcs (multiblockcarriers | singleblockcarriers)
  +%% CallGroup         -> calls
  +%% Type              -> CarrierType | CallType
  +%% CarrierType       -> sys | mseg | blocks
  +%% CallType          -> AllocatorSpecific | sys | mseg
  +%% AllocatorSpecific -> AllocatorName
  +%% Info              -> CallInfo | CarrierInfo
  +%% CallInfo          -> alloc | realloc | dealloc | free
  +%% CarrierInfo       -> count | size
  +%% Count             -> size in bytes | counts
   %% @end
   
   -module('atop').
  
positive.code:     end,
      PL).
  
  aggr(Inds,List) ->
    lists:foldl(mkaggfun(Inds),[],lists:sort(mksortfun(Inds),List)).
  
  mkaggfun(Inds) ->
    fun({K,V},[]) -> [{mknewkey(K,Inds),V}];
  
negative.code: -export([aggregate/0,aggregate/1,aggregate/2]).
  
  aggregate() ->
    aggregate(indices()--[instance]).
  aggregate(AggregateIndices) ->
    aggregate(AggregateIndices,[]).
  aggregate(AggregateIndices,FilterTags) ->
    aggr(
      AggregateIndices,
      filter(
        FilterTags,
        getallocdata())).
  
  allocs() ->
    allocs(allocd).
  allocs(SortCol) ->
    allocs(SortCol,[allocator,group]).
  allocs(SortCol,AggregateIndices) ->
    printh(AggregateIndices,columns()),
    lists:foreach(
      fun print/1,
      lists:reverse(
        lists:keysort(
          column2index(SortCol),
          lists:foldl(
            fun present/2,
            [],
            filter(
              [size],
              aggr(
                AggregateIndices++[type,info],
                getallocdata())))))).
  
  printh(AggInds,Cols) ->
    io:fwrite("~-33w~8w~8w~8w~n",[AggInds]++tl(Cols)).
  print({K,T,U,F}) ->
    io:fwrite("~-33w~8.2f~8.2f~8.2f~n",[K,T,U,F]).
  
  