Ejemplo n.º 1
0
def main(argv):
    filename = argv[0]

    histograms = list(histogram_tools.from_file(filename))

    print banner
    write_histogram_table(histograms)
    write_histogram_static_asserts(histograms)
Ejemplo n.º 2
0
def main(argv):
    filename = argv[0]

    histograms = list(histogram_tools.from_file(filename))

    print banner
    write_histogram_table(histograms)
    write_histogram_static_asserts(histograms)
Ejemplo n.º 3
0
def get(filename):
    ret = {}
    for h in histogram_tools.from_file(filename):
        try:
            ret[h.name()] = h.ranges()
        except:
            sys.stderr.write("Could not figure out bucket range for %s\n" %
                             h.name())
    return ret
Ejemplo n.º 4
0
def get(filename):
    ret = {}
    for h in histogram_tools.from_file(filename):
        try:
            ret[h.name()] = h.ranges()
        except:
            sys.stderr.write("Could not figure out bucket range for %s\n"
                             % h.name())
    return ret
Ejemplo n.º 5
0
def main(argv):
    filename = argv[0]

    print banner
    print "enum ID {"
    for histogram in histogram_tools.from_file(filename):
        cpp_guard = histogram.cpp_guard()
        if cpp_guard:
            print "#if defined(%s)" % cpp_guard
        print "  %s," % histogram.name()
        if cpp_guard:
            print "#endif"
    print "  HistogramCount"
    print "};"
Ejemplo n.º 6
0
def main(argv):
    filename = argv[0]

    print banner
    print "enum ID {"
    for (name, definition) in histogram_tools.from_file(filename):
        cpp_guard = definition.get('cpp_guard')
        if cpp_guard:
            print "#if defined(%s)" % cpp_guard
        print "  %s," % (name,)
        if cpp_guard:
            print "#endif"
    print "  HistogramCount"
    print "};"
Ejemplo n.º 7
0
def main(argv):
    filename = argv[0]
    all_histograms = OrderedDict()

    for histogram in histogram_tools.from_file(filename):
        name = histogram.name()
        parameters = OrderedDict()
        table = {
            'boolean': '2',
            'flag': '3',
            'enumerated': '1',
            'linear': '1',
            'exponential': '0',
            'count': '4',
        }
        # Use __setitem__ because Python lambdas are so limited.
        histogram_tools.table_dispatch(
            histogram.kind(), table,
            lambda k: parameters.__setitem__('kind', k))
        if histogram.low() == 0:
            parameters['min'] = 1
        else:
            parameters['min'] = histogram.low()

        try:
            buckets = histogram.ranges()
            parameters['buckets'] = buckets
            parameters['max'] = buckets[-1]
            parameters['bucket_count'] = len(buckets)
        except histogram_tools.DefinitionException:
            continue

        all_histograms.update({name: parameters})

        if startup_histogram_re.search(name) is not None:
            all_histograms.update({"STARTUP_" + name: parameters})

    print json.dumps({'histograms': all_histograms})
def main(argv):
    filename = argv[0]
    all_histograms = OrderedDict()

    for histogram in histogram_tools.from_file(filename):
        name = histogram.name()
        parameters = OrderedDict()
        table = {
            'boolean': '2',
            'flag': '3',
            'enumerated': '1',
            'linear': '1',
            'exponential': '0',
            'count': '4',
            }
        # Use __setitem__ because Python lambdas are so limited.
        histogram_tools.table_dispatch(histogram.kind(), table,
                                       lambda k: parameters.__setitem__('kind', k))
        if histogram.low() == 0:
            parameters['min'] = 1
        else:
            parameters['min'] = histogram.low()

        try:
            buckets = histogram.ranges()
            parameters['buckets'] = buckets
            parameters['max'] = buckets[-1]
            parameters['bucket_count'] = len(buckets)
        except histogram_tools.DefinitionException:
            continue

        all_histograms.update({ name: parameters });

        if startup_histogram_re.search(name) is not None:
            all_histograms.update({ "STARTUP_" + name: parameters })

    print json.dumps({ 'histograms': all_histograms})
Ejemplo n.º 9
0
import os

try:
    import simplejson as json

    print "Using simplejson for faster json parsing"
except ImportError:
    import json

import histogram_tools

f = sys.stdin
outdir = sys.argv[1]

histogram_specs = {}
for h in histogram_tools.from_file(sys.argv[2]):
    try:
        histogram_specs[h.name()] = h.ranges()
    except:
        print "Could not figure out bucket range for %s" % h.name()


def readExisting(filename, default):
    try:
        f = open(filename)
        obj = json.loads(f.read())
        f.close()
        print "Read " + filename
        return obj
    except IOError:
        return default
Ejemplo n.º 10
0
import sys
import os.path
import os
try:
    import simplejson as json
    print "Using simplejson for faster json parsing"
except ImportError:
    import json

import histogram_tools

f = sys.stdin
outdir = sys.argv[1]

histogram_specs = {}
for h in histogram_tools.from_file(sys.argv[2]):
    try:
        histogram_specs[h.name()] = h.ranges()
    except:
        print "Could not figure out bucket range for %s" % h.name()


def readExisting(filename, default):
    try:
        f = open(filename)
        obj = json.loads(f.read())
        f.close()
        print "Read " + filename
        return obj
    except IOError:
        return default