aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/codegen/core/gen_stats_data.py
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-09-01 16:36:52 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-09-01 16:36:52 -0700
commit56a84848c7b683e6e7fb3bef8b37364f9984cfdb (patch)
tree1b3bdae104ea63334572186ebf192ccb2de08fbb /tools/codegen/core/gen_stats_data.py
parent40bca8468e91e5e8a9df0b84b30458bf79a3acc3 (diff)
parentda5cd59ed3f383318fb01b1bf461489cc828d453 (diff)
Merge branch 'stats_histo_ints' into stats_histo
Diffstat (limited to 'tools/codegen/core/gen_stats_data.py')
-rwxr-xr-xtools/codegen/core/gen_stats_data.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/tools/codegen/core/gen_stats_data.py b/tools/codegen/core/gen_stats_data.py
index 36f2ec2c3e..857c99da8d 100755
--- a/tools/codegen/core/gen_stats_data.py
+++ b/tools/codegen/core/gen_stats_data.py
@@ -111,16 +111,19 @@ def gen_bucket_code(histogram):
first_nontrivial = None
first_unmapped = None
while len(bounds) < histogram.buckets:
- mul = math.pow(float(histogram.max) / bounds[-1],
- 1.0 / (histogram.buckets - len(bounds)))
- nextb = bounds[-1] * mul
- if nextb < bounds[-1] + 1:
+ if len(bounds) == histogram.buckets - 1:
+ nextb = int(histogram.max)
+ else:
+ mul = math.pow(float(histogram.max) / bounds[-1],
+ 1.0 / (histogram.buckets - len(bounds)))
+ nextb = int(math.ceil(bounds[-1] * mul))
+ if nextb <= bounds[-1] + 1:
nextb = bounds[-1] + 1
elif not done_trivial:
done_trivial = True
first_nontrivial = len(bounds)
bounds.append(nextb)
- bounds_idx = decl_static_table(bounds, 'double')
+ bounds_idx = decl_static_table(bounds, 'int')
if done_trivial:
first_nontrivial_code = dbl2u64(first_nontrivial)
code_bounds = [dbl2u64(x) - first_nontrivial_code for x in bounds]
@@ -216,17 +219,18 @@ with open('src/core/lib/debug/stats_data.h', 'w') as H:
"GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_%s)") % (
ctr.name.upper(), ctr.name.upper())
for histogram in inst_map['Histogram']:
- print >>H, "#define GRPC_STATS_INC_%s(exec_ctx, value) grpc_stats_inc_%s((exec_ctx), (double)(value))" % (
+ print >>H, "#define GRPC_STATS_INC_%s(exec_ctx, value) grpc_stats_inc_%s((exec_ctx), (int)(value))" % (
histogram.name.upper(), histogram.name.lower())
- print >>H, "void grpc_stats_inc_%s(grpc_exec_ctx *exec_ctx, double x);" % histogram.name.lower()
+ print >>H, "void grpc_stats_inc_%s(grpc_exec_ctx *exec_ctx, int x);" % histogram.name.lower()
for i, tbl in enumerate(static_tables):
print >>H, "extern const %s grpc_stats_table_%d[%d];" % (tbl[0], i, len(tbl[1]))
print >>H, "extern const int grpc_stats_histo_buckets[%d];" % len(inst_map['Histogram'])
print >>H, "extern const int grpc_stats_histo_start[%d];" % len(inst_map['Histogram'])
+ print >>H, "extern const int *const grpc_stats_histo_bucket_boundaries[%d];" % len(inst_map['Histogram'])
print >>H, "extern const double *const grpc_stats_histo_bucket_boundaries[%d];" % len(inst_map['Histogram'])
- print >>H, "extern void (*const grpc_stats_inc_histogram[%d])(grpc_exec_ctx *exec_ctx, double x);" % len(inst_map['Histogram'])
+ print >>H, "extern void (*const grpc_stats_inc_histogram[%d])(grpc_exec_ctx *exec_ctx, int x);" % len(inst_map['Histogram'])
print >>H
print >>H, "#endif /* GRPC_CORE_LIB_DEBUG_STATS_DATA_H */"
@@ -278,7 +282,7 @@ with open('src/core/lib/debug/stats_data.c', 'w') as C:
len(inst_map['Histogram']), ','.join('%s' % x for x in histo_buckets))
print >>C, "const int grpc_stats_histo_start[%d] = {%s};" % (
len(inst_map['Histogram']), ','.join('%s' % x for x in histo_start))
- print >>C, "const double *const grpc_stats_histo_bucket_boundaries[%d] = {%s};" % (
+ print >>C, "const int *const grpc_stats_histo_bucket_boundaries[%d] = {%s};" % (
len(inst_map['Histogram']), ','.join('grpc_stats_table_%d' % x for x in histo_bucket_boundaries))
print >>C, "void (*const grpc_stats_inc_histogram[%d])(grpc_exec_ctx *exec_ctx, double x) = {%s};" % (
len(inst_map['Histogram']), ','.join('grpc_stats_inc_%s' % histogram.name.lower() for histogram in inst_map['Histogram']))