aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/codegen/core/gen_stats_data.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/codegen/core/gen_stats_data.py')
-rwxr-xr-xtools/codegen/core/gen_stats_data.py44
1 files changed, 26 insertions, 18 deletions
diff --git a/tools/codegen/core/gen_stats_data.py b/tools/codegen/core/gen_stats_data.py
index 5c9d9e5ea5..0f61c3e237 100755
--- a/tools/codegen/core/gen_stats_data.py
+++ b/tools/codegen/core/gen_stats_data.py
@@ -230,13 +230,11 @@ with open('src/core/lib/debug/stats_data.h', 'w') as H:
print >> H, "#ifndef GRPC_CORE_LIB_DEBUG_STATS_DATA_H"
print >> H, "#define GRPC_CORE_LIB_DEBUG_STATS_DATA_H"
print >> H
+ print >> H, "#include <grpc/support/port_platform.h>"
+ print >> H
print >> H, "#include <inttypes.h>"
print >> H, "#include \"src/core/lib/iomgr/exec_ctx.h\""
print >> H
- print >> H, "#ifdef __cplusplus"
- print >> H, "extern \"C\" {"
- print >> H, "#endif"
- print >> H
for typename, instances in sorted(inst_map.items()):
print >> H, "typedef enum {"
@@ -267,6 +265,7 @@ with open('src/core/lib/debug/stats_data.h', 'w') as H:
print >> H, " GRPC_STATS_HISTOGRAM_BUCKETS = %d" % first_slot
print >> H, "} grpc_stats_histogram_constants;"
+ print >> H, "#if defined(GRPC_COLLECT_STATS) || !defined(NDEBUG)"
for ctr in inst_map['Counter']:
print >> H, ("#define GRPC_STATS_INC_%s() " +
"GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_%s)") % (
@@ -276,6 +275,14 @@ with open('src/core/lib/debug/stats_data.h', 'w') as H:
histogram.name.upper(), histogram.name.lower())
print >> H, "void grpc_stats_inc_%s(int x);" % histogram.name.lower()
+ print >> H, "#else"
+ for ctr in inst_map['Counter']:
+ print >> H, ("#define GRPC_STATS_INC_%s() ") % (ctr.name.upper())
+ for histogram in inst_map['Histogram']:
+ print >> H, "#define GRPC_STATS_INC_%s(value)" % (
+ histogram.name.upper())
+ print >> H, "#endif /* defined(GRPC_COLLECT_STATS) || !defined(NDEBUG) */"
+
for i, tbl in enumerate(static_tables):
print >> H, "extern const %s grpc_stats_table_%d[%d];" % (tbl[0], i,
len(tbl[1]))
@@ -290,10 +297,6 @@ with open('src/core/lib/debug/stats_data.h', 'w') as H:
inst_map['Histogram'])
print >> H
- print >> H, "#ifdef __cplusplus"
- print >> H, "}"
- print >> H, "#endif"
- print >> H
print >> H, "#endif /* GRPC_CORE_LIB_DEBUG_STATS_DATA_H */"
with open('src/core/lib/debug/stats_data.cc', 'w') as C:
@@ -316,10 +319,13 @@ with open('src/core/lib/debug/stats_data.cc', 'w') as C:
[C],
["Automatically generated by tools/codegen/core/gen_stats_data.py"])
- print >> C, "#include \"src/core/lib/debug/stats_data.h\""
+ print >> C, "#include <grpc/support/port_platform.h>"
+ print >> C
print >> C, "#include \"src/core/lib/debug/stats.h\""
+ print >> C, "#include \"src/core/lib/debug/stats_data.h\""
+ print >> C, "#include \"src/core/lib/gpr/useful.h\""
print >> C, "#include \"src/core/lib/iomgr/exec_ctx.h\""
- print >> C, "#include <grpc/support/useful.h>"
+ print >> C
histo_code = []
for histogram in inst_map['Histogram']:
@@ -439,18 +445,20 @@ with open('tools/run_tests/performance/massage_qps_stats.py', 'w') as P:
print >> P, 'def massage_qps_stats(scenario_result):'
print >> P, ' for stats in scenario_result["serverStats"] + scenario_result["clientStats"]:'
- print >> P, ' if "coreStats" not in stats: return'
- print >> P, ' core_stats = stats["coreStats"]'
- print >> P, ' del stats["coreStats"]'
+ print >> P, ' if "coreStats" in stats:'
+ print >> P, ' # Get rid of the "coreStats" element and replace it by statistics'
+ print >> P, ' # that correspond to columns in the bigquery schema.'
+ print >> P, ' core_stats = stats["coreStats"]'
+ print >> P, ' del stats["coreStats"]'
for counter in inst_map['Counter']:
- print >> P, ' stats["core_%s"] = massage_qps_stats_helpers.counter(core_stats, "%s")' % (
+ print >> P, ' stats["core_%s"] = massage_qps_stats_helpers.counter(core_stats, "%s")' % (
counter.name, counter.name)
for i, histogram in enumerate(inst_map['Histogram']):
- print >> P, ' h = massage_qps_stats_helpers.histogram(core_stats, "%s")' % histogram.name
- print >> P, ' stats["core_%s"] = ",".join("%%f" %% x for x in h.buckets)' % histogram.name
- print >> P, ' stats["core_%s_bkts"] = ",".join("%%f" %% x for x in h.boundaries)' % histogram.name
+ print >> P, ' h = massage_qps_stats_helpers.histogram(core_stats, "%s")' % histogram.name
+ print >> P, ' stats["core_%s"] = ",".join("%%f" %% x for x in h.buckets)' % histogram.name
+ print >> P, ' stats["core_%s_bkts"] = ",".join("%%f" %% x for x in h.boundaries)' % histogram.name
for pctl in RECORD_EXPLICIT_PERCENTILES:
- print >> P, ' stats["core_%s_%dp"] = massage_qps_stats_helpers.percentile(h.buckets, %d, h.boundaries)' % (
+ print >> P, ' stats["core_%s_%dp"] = massage_qps_stats_helpers.percentile(h.buckets, %d, h.boundaries)' % (
histogram.name, pctl, pctl)
with open('src/core/lib/debug/stats_data_bq_schema.sql', 'w') as S: