summaryrefslogtreecommitdiffstats
path: root/vespamalloc/src/vespamalloc/util/traceutil.cpp
blob: 149124a06be8d7ef5313011d1dbfdd3fde9ca83d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespamalloc/util/traceutil.h>
#include <algorithm>

namespace vespamalloc {

Aggregator::Aggregator()
{
}

Aggregator::~Aggregator()
{
}

struct CmpGraph
{
    bool operator () (const std::pair<size_t, string> & a, const std::pair<size_t, string> & b) const {
        return a.first < b.first;
    }
};

asciistream & operator << (asciistream & os, const Aggregator & v)
{
    Aggregator::Map map(v._map);
    std::sort(map.begin(), map.end(), CmpGraph());
    for (Aggregator::Map::const_iterator it=map.begin(); it != map.end(); it++) {
        os << it->first << " : " << it->second.c_str() << '\n';
    }
    return os;
}

}