Пример #1
0
def main(argv):
    filenames = argv

    all_histograms = OrderedDict()

    for histogram in histogram_tools.from_files(filenames):
        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 })

    print json.dumps({ 'histograms': all_histograms})
def main(argv):
    filenames = argv

    all_histograms = OrderedDict()

    for histogram in histogram_tools.from_files(filenames):
        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 });

    print json.dumps({ 'histograms': all_histograms})
def main(argv):
    filenames = argv

    all_histograms = OrderedDict()

    for histogram in histogram_tools.from_files(filenames):
        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})
Пример #4
0
def write_histogram_static_asserts(histograms):
    print """
// Perform the checks at the beginning of HistogramGet at
// compile time, so that incorrect histogram definitions
// give compile-time errors, not runtime errors."""

    table = {
        "boolean": static_asserts_for_boolean,
        "flag": static_asserts_for_flag,
        "enumerated": static_asserts_for_enumerated,
        "linear": static_asserts_for_linear,
        "exponential": static_asserts_for_exponential,
    }

    for histogram in histograms:
        histogram_tools.table_dispatch(histogram.kind(), table, lambda f: f(histogram))
Пример #5
0
def write_histogram_static_asserts(histograms):
    print """
// Perform the checks at the beginning of HistogramGet at
// compile time, so that incorrect histogram definitions
// give compile-time errors, not runtime errors."""

    table = {
        'boolean': static_asserts_for_boolean,
        'flag': static_asserts_for_flag,
        'enumerated': static_asserts_for_enumerated,
        'linear': static_asserts_for_linear,
        'exponential': static_asserts_for_exponential,
    }

    for histogram in histograms:
        histogram_tools.table_dispatch(histogram.kind(), table,
                                       lambda f: f(histogram))
Пример #6
0
def write_histogram_static_asserts(output, histograms):
    print("""
// Perform the checks at the beginning of HistogramGet at
// compile time, so that incorrect histogram definitions
// give compile-time errors, not runtime errors.""", file=output)

    table = {
        'boolean' : static_asserts_for_boolean,
        'flag' : static_asserts_for_flag,
        'count': static_asserts_for_count,
        'enumerated' : static_asserts_for_enumerated,
        'linear' : static_asserts_for_linear,
        'exponential' : static_asserts_for_exponential,
        }

    for histogram in histograms:
        histogram_tools.table_dispatch(histogram.kind(), table,
                                       lambda f: f(output, histogram))