Exemplo n.º 1
0
def process_stats(stats):
    """Process stats and returns a list of (label, count, time) for each entry.

    Entries like "memcache.get" and "memcache.set" will be collapsed into "memcache".
    """
    d = {}
    for name, value in stats.items():
        name = name.split(".")[0]

        label = labels.get(name, "OT")
        count = value.get("count", 0)
        time = value.get("time", 0.0)

        xcount, xtime = d.get(label, [0, 0])
        d[label] = xcount + count, xtime + time

    return [(label, count, time) for label, (count, time) in sorted(d.items())]
Exemplo n.º 2
0
def process_stats(stats):
    """Process stats and returns a list of (label, count, time) for each entry.
    
    Entries like "memcache.get" and "memcache.set" will be collapsed into "memcache".
    """
    d = {}
    for name, value in stats.items():
        name = name.split(".")[0]
        
        label = labels.get(name, "OT")
        count = value.get("count", 0)
        time = value.get("time", 0.0)
        
        xcount, xtime = d.get(label, [0, 0])
        d[label] = xcount + count, xtime + time
        
    return [(label, count, time) for label, (count, time) in sorted(d.items())]