def write_histogram_table(output, histograms): string_table = StringTable() label_table = [] label_count = 0 print("const HistogramInfo gHistograms[] = {", file=output) for histogram in histograms: name_index = string_table.stringIndex(histogram.name()) exp_index = string_table.stringIndex(histogram.expiration()) labels = histogram.labels() label_index = 0 if len(labels) > 0: label_index = label_count label_table.append( (histogram.name(), string_table.stringIndexes(labels))) label_count += len(labels) print_array_entry(output, histogram, name_index, exp_index, label_index, len(labels)) print("};\n", file=output) strtab_name = "gHistogramStringTable" string_table.writeDefinition(output, strtab_name) static_assert(output, "sizeof(%s) <= UINT32_MAX" % strtab_name, "index overflow") print("\nconst uint32_t gHistogramLabelTable[] = {", file=output) for name, indexes in label_table: print("/* %s */ %s," % (name, ", ".join(map(str, indexes))), file=output) print("};", file=output)
def write_histogram_table(output, histograms): string_table = StringTable() label_table = [] label_count = 0 print("const HistogramInfo gHistograms[] = {", file=output) for histogram in histograms: name_index = string_table.stringIndex(histogram.name()) exp_index = string_table.stringIndex(histogram.expiration()) labels = histogram.labels() label_index = 0 if len(labels) > 0: label_index = label_count label_table.append((histogram.name(), string_table.stringIndexes(labels))) label_count += len(labels) print_array_entry(output, histogram, name_index, exp_index, label_index, len(labels)) print("};\n", file=output) strtab_name = "gHistogramStringTable" string_table.writeDefinition(output, strtab_name) static_assert(output, "sizeof(%s) <= UINT32_MAX" % strtab_name, "index overflow") print("\nconst uint32_t gHistogramLabelTable[] = {", file=output) for name,indexes in label_table: print("/* %s */ %s," % (name, ", ".join(map(str, indexes))), file=output) print("};", file=output)
def write_histogram_table(output, histograms): table = StringTable() print("const HistogramInfo gHistograms[] = {", file=output) for histogram in histograms: name_index = table.stringIndex(histogram.name()) exp_index = table.stringIndex(histogram.expiration()) print_array_entry(output, histogram, name_index, exp_index) print("};", file=output) strtab_name = "gHistogramStringTable" table.writeDefinition(output, strtab_name) static_assert(output, "sizeof(%s) <= UINT32_MAX" % strtab_name, "index overflow")
def write_histogram_table(output, histograms): table = StringTable() print("const HistogramInfo gHistograms[] = {", file=output) for histogram in histograms: name_index = table.stringIndex(histogram.name()) exp_index = table.stringIndex(histogram.expiration()) print_array_entry(output, histogram, name_index, exp_index) print("};", file=output) strtab_name = "gHistogramStringTable" table.writeDefinition(output, strtab_name) static_assert(output, "sizeof(%s) <= UINT32_MAX" % strtab_name, "index overflow")
def write_scalar_tables(scalars, output): """Writes the scalar and strings tables to an header file. :param scalars: a list of ScalarType instances describing the scalars. :param output: the output stream. """ string_table = StringTable() print("const ScalarInfo gScalars[] = {", file=output) for s in scalars: # We add both the scalar label and the expiration string to the strings # table. name_index = string_table.stringIndex(s.label) exp_index = string_table.stringIndex(s.expires) # Write the scalar info entry. write_scalar_info(s, output, name_index, exp_index) print("};", file=output) string_table_name = "gScalarsStringTable" string_table.writeDefinition(output, string_table_name) static_assert(output, "sizeof(%s) <= UINT32_MAX" % string_table_name, "index overflow")
def write_scalar_tables(scalars, output): """Writes the scalar and strings tables to an header file. :param scalars: a list of ScalarType instances describing the scalars. :param output: the output stream. """ string_table = StringTable() print("const ScalarInfo gScalars[] = {", file=output) for s in scalars: # We add both the scalar label and the expiration string to the strings # table. name_index = string_table.stringIndex(s.label) exp_index = string_table.stringIndex(s.expires) # Write the scalar info entry. write_scalar_info(s, output, name_index, exp_index) print("};", file=output) string_table_name = "gScalarsStringTable" string_table.writeDefinition(output, string_table_name) static_assert(output, "sizeof(%s) <= UINT32_MAX" % string_table_name, "index overflow")