aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--BUILD5
-rw-r--r--CMakeLists.txt63
-rw-r--r--Makefile79
-rw-r--r--build.yaml22
-rw-r--r--config.m41
-rw-r--r--config.w321
-rw-r--r--gRPC-Core.podspec2
-rw-r--r--grpc.def15
-rw-r--r--grpc.gemspec2
-rw-r--r--grpc.gyp3
-rw-r--r--include/grpc/module.modulemap1
-rw-r--r--include/grpc/support/histogram.h64
-rw-r--r--package.xml2
-rw-r--r--src/python/grpcio/grpc_core_dependencies.py1
-rw-r--r--src/ruby/ext/grpc/rb_grpc_imports.generated.c30
-rw-r--r--src/ruby/ext/grpc/rb_grpc_imports.generated.h46
-rw-r--r--test/core/fling/client.cc18
-rw-r--r--test/core/network_benchmarks/low_level_ping_pong.cc18
-rw-r--r--test/core/support/BUILD10
-rw-r--r--test/core/support/histogram_test.cc163
-rw-r--r--test/core/surface/public_headers_must_be_c89.c16
-rw-r--r--test/core/util/BUILD25
-rw-r--r--test/core/util/histogram.cc (renamed from src/core/lib/support/histogram.cc)62
-rw-r--r--test/core/util/histogram.h62
-rw-r--r--test/core/util/histogram_test.cc163
-rw-r--r--test/cpp/qps/BUILD2
-rw-r--r--test/cpp/qps/histogram.h36
-rw-r--r--test/cpp/qps/qps_interarrival_test.cc10
-rw-r--r--test/cpp/qps/qps_worker.cc2
-rw-r--r--tools/doxygen/Doxyfile.c++1
-rw-r--r--tools/doxygen/Doxyfile.c++.internal1
-rw-r--r--tools/doxygen/Doxyfile.core1
-rw-r--r--tools/doxygen/Doxyfile.core.internal2
-rw-r--r--tools/run_tests/generated/sources_and_headers.json36
-rw-r--r--tools/run_tests/generated/tests.json48
35 files changed, 444 insertions, 569 deletions
diff --git a/BUILD b/BUILD
index d904a1ec6e..82ac73f014 100644
--- a/BUILD
+++ b/BUILD
@@ -54,7 +54,6 @@ GPR_PUBLIC_HDRS = [
"include/grpc/support/avl.h",
"include/grpc/support/cmdline.h",
"include/grpc/support/cpu.h",
- "include/grpc/support/histogram.h",
"include/grpc/support/host_port.h",
"include/grpc/support/log.h",
"include/grpc/support/log_windows.h",
@@ -79,10 +78,11 @@ GRPC_PUBLIC_HDRS = [
"include/grpc/byte_buffer.h",
"include/grpc/byte_buffer_reader.h",
"include/grpc/compression.h",
- "include/grpc/load_reporting.h",
+ "include/grpc/fork.h",
"include/grpc/grpc.h",
"include/grpc/grpc_posix.h",
"include/grpc/grpc_security_constants.h",
+ "include/grpc/load_reporting.h",
"include/grpc/slice.h",
"include/grpc/slice_buffer.h",
"include/grpc/status.h",
@@ -446,7 +446,6 @@ grpc_cc_library(
"src/core/lib/support/env_posix.cc",
"src/core/lib/support/env_windows.cc",
"src/core/lib/support/fork.cc",
- "src/core/lib/support/histogram.cc",
"src/core/lib/support/host_port.cc",
"src/core/lib/support/log.cc",
"src/core/lib/support/log_android.cc",
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 760e4fa585..ab57f662cf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -427,7 +427,6 @@ add_dependencies(buildtests_c gpr_avl_test)
add_dependencies(buildtests_c gpr_cmdline_test)
add_dependencies(buildtests_c gpr_cpu_test)
add_dependencies(buildtests_c gpr_env_test)
-add_dependencies(buildtests_c gpr_histogram_test)
add_dependencies(buildtests_c gpr_host_port_test)
add_dependencies(buildtests_c gpr_log_test)
add_dependencies(buildtests_c gpr_manual_constructor_test)
@@ -465,6 +464,7 @@ endif()
if(_gRPC_PLATFORM_LINUX)
add_dependencies(buildtests_c handshake_server_with_readahead_handshaker)
endif()
+add_dependencies(buildtests_c histogram_test)
add_dependencies(buildtests_c hpack_parser_test)
add_dependencies(buildtests_c hpack_table_test)
add_dependencies(buildtests_c http_parser_test)
@@ -799,7 +799,6 @@ add_library(gpr
src/core/lib/support/env_posix.cc
src/core/lib/support/env_windows.cc
src/core/lib/support/fork.cc
- src/core/lib/support/histogram.cc
src/core/lib/support/host_port.cc
src/core/lib/support/log.cc
src/core/lib/support/log_android.cc
@@ -869,7 +868,6 @@ foreach(_hdr
include/grpc/support/avl.h
include/grpc/support/cmdline.h
include/grpc/support/cpu.h
- include/grpc/support/histogram.h
include/grpc/support/host_port.h
include/grpc/support/log.h
include/grpc/support/log_windows.h
@@ -1617,6 +1615,7 @@ add_library(grpc_test_util
test/core/iomgr/endpoint_tests.cc
test/core/util/debugger_macros.cc
test/core/util/grpc_profiler.cc
+ test/core/util/histogram.cc
test/core/util/memory_counters.cc
test/core/util/mock_endpoint.cc
test/core/util/parse_hexstring.cc
@@ -1885,6 +1884,7 @@ add_library(grpc_test_util_unsecure
test/core/iomgr/endpoint_tests.cc
test/core/util/debugger_macros.cc
test/core/util/grpc_profiler.cc
+ test/core/util/histogram.cc
test/core/util/memory_counters.cc
test/core/util/mock_endpoint.cc
test/core/util/parse_hexstring.cc
@@ -2671,7 +2671,6 @@ foreach(_hdr
include/grpc/support/avl.h
include/grpc/support/cmdline.h
include/grpc/support/cpu.h
- include/grpc/support/histogram.h
include/grpc/support/host_port.h
include/grpc/support/log.h
include/grpc/support/log_windows.h
@@ -3158,7 +3157,6 @@ foreach(_hdr
include/grpc/support/avl.h
include/grpc/support/cmdline.h
include/grpc/support/cpu.h
- include/grpc/support/histogram.h
include/grpc/support/host_port.h
include/grpc/support/log.h
include/grpc/support/log_windows.h
@@ -3905,7 +3903,6 @@ foreach(_hdr
include/grpc/support/avl.h
include/grpc/support/cmdline.h
include/grpc/support/cpu.h
- include/grpc/support/histogram.h
include/grpc/support/host_port.h
include/grpc/support/log.h
include/grpc/support/log_windows.h
@@ -6259,33 +6256,6 @@ target_link_libraries(gpr_env_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
-add_executable(gpr_histogram_test
- test/core/support/histogram_test.cc
-)
-
-
-target_include_directories(gpr_histogram_test
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
- PRIVATE ${BORINGSSL_ROOT_DIR}/include
- PRIVATE ${PROTOBUF_ROOT_DIR}/src
- PRIVATE ${BENCHMARK_ROOT_DIR}/include
- PRIVATE ${ZLIB_ROOT_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
- PRIVATE ${CARES_INCLUDE_DIR}
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
- PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
-)
-
-target_link_libraries(gpr_histogram_test
- ${_gRPC_ALLTARGETS_LIBRARIES}
- gpr_test_util
- gpr
-)
-
-endif (gRPC_BUILD_TESTS)
-if (gRPC_BUILD_TESTS)
-
add_executable(gpr_host_port_test
test/core/support/host_port_test.cc
)
@@ -7221,6 +7191,33 @@ endif()
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+add_executable(histogram_test
+ test/core/util/histogram_test.cc
+)
+
+
+target_include_directories(histogram_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${BORINGSSL_ROOT_DIR}/include
+ PRIVATE ${PROTOBUF_ROOT_DIR}/src
+ PRIVATE ${BENCHMARK_ROOT_DIR}/include
+ PRIVATE ${ZLIB_ROOT_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
+ PRIVATE ${CARES_INCLUDE_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
+)
+
+target_link_libraries(histogram_test
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ gpr
+)
+
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
+
add_executable(hpack_parser_test
test/core/transport/chttp2/hpack_parser_test.cc
)
diff --git a/Makefile b/Makefile
index 3ce3005924..bd83244a61 100644
--- a/Makefile
+++ b/Makefile
@@ -988,7 +988,6 @@ gpr_avl_test: $(BINDIR)/$(CONFIG)/gpr_avl_test
gpr_cmdline_test: $(BINDIR)/$(CONFIG)/gpr_cmdline_test
gpr_cpu_test: $(BINDIR)/$(CONFIG)/gpr_cpu_test
gpr_env_test: $(BINDIR)/$(CONFIG)/gpr_env_test
-gpr_histogram_test: $(BINDIR)/$(CONFIG)/gpr_histogram_test
gpr_host_port_test: $(BINDIR)/$(CONFIG)/gpr_host_port_test
gpr_log_test: $(BINDIR)/$(CONFIG)/gpr_log_test
gpr_manual_constructor_test: $(BINDIR)/$(CONFIG)/gpr_manual_constructor_test
@@ -1021,6 +1020,7 @@ grpc_verify_jwt: $(BINDIR)/$(CONFIG)/grpc_verify_jwt
handshake_client: $(BINDIR)/$(CONFIG)/handshake_client
handshake_server: $(BINDIR)/$(CONFIG)/handshake_server
handshake_server_with_readahead_handshaker: $(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker
+histogram_test: $(BINDIR)/$(CONFIG)/histogram_test
hpack_parser_fuzzer_test: $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test
hpack_parser_test: $(BINDIR)/$(CONFIG)/hpack_parser_test
hpack_table_test: $(BINDIR)/$(CONFIG)/hpack_table_test
@@ -1383,7 +1383,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/gpr_cmdline_test \
$(BINDIR)/$(CONFIG)/gpr_cpu_test \
$(BINDIR)/$(CONFIG)/gpr_env_test \
- $(BINDIR)/$(CONFIG)/gpr_histogram_test \
$(BINDIR)/$(CONFIG)/gpr_host_port_test \
$(BINDIR)/$(CONFIG)/gpr_log_test \
$(BINDIR)/$(CONFIG)/gpr_manual_constructor_test \
@@ -1413,6 +1412,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/handshake_client \
$(BINDIR)/$(CONFIG)/handshake_server \
$(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker \
+ $(BINDIR)/$(CONFIG)/histogram_test \
$(BINDIR)/$(CONFIG)/hpack_parser_test \
$(BINDIR)/$(CONFIG)/hpack_table_test \
$(BINDIR)/$(CONFIG)/http_parser_test \
@@ -1829,8 +1829,6 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/gpr_cpu_test || ( echo test gpr_cpu_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_env_test"
$(Q) $(BINDIR)/$(CONFIG)/gpr_env_test || ( echo test gpr_env_test failed ; exit 1 )
- $(E) "[RUN] Testing gpr_histogram_test"
- $(Q) $(BINDIR)/$(CONFIG)/gpr_histogram_test || ( echo test gpr_histogram_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_host_port_test"
$(Q) $(BINDIR)/$(CONFIG)/gpr_host_port_test || ( echo test gpr_host_port_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_log_test"
@@ -1887,6 +1885,8 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/handshake_server || ( echo test handshake_server failed ; exit 1 )
$(E) "[RUN] Testing handshake_server_with_readahead_handshaker"
$(Q) $(BINDIR)/$(CONFIG)/handshake_server_with_readahead_handshaker || ( echo test handshake_server_with_readahead_handshaker failed ; exit 1 )
+ $(E) "[RUN] Testing histogram_test"
+ $(Q) $(BINDIR)/$(CONFIG)/histogram_test || ( echo test histogram_test failed ; exit 1 )
$(E) "[RUN] Testing hpack_parser_test"
$(Q) $(BINDIR)/$(CONFIG)/hpack_parser_test || ( echo test hpack_parser_test failed ; exit 1 )
$(E) "[RUN] Testing hpack_table_test"
@@ -2829,7 +2829,6 @@ LIBGPR_SRC = \
src/core/lib/support/env_posix.cc \
src/core/lib/support/env_windows.cc \
src/core/lib/support/fork.cc \
- src/core/lib/support/histogram.cc \
src/core/lib/support/host_port.cc \
src/core/lib/support/log.cc \
src/core/lib/support/log_android.cc \
@@ -2869,7 +2868,6 @@ PUBLIC_HEADERS_C += \
include/grpc/support/avl.h \
include/grpc/support/cmdline.h \
include/grpc/support/cpu.h \
- include/grpc/support/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
@@ -3623,6 +3621,7 @@ LIBGRPC_TEST_UTIL_SRC = \
test/core/iomgr/endpoint_tests.cc \
test/core/util/debugger_macros.cc \
test/core/util/grpc_profiler.cc \
+ test/core/util/histogram.cc \
test/core/util/memory_counters.cc \
test/core/util/mock_endpoint.cc \
test/core/util/parse_hexstring.cc \
@@ -3882,6 +3881,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \
test/core/iomgr/endpoint_tests.cc \
test/core/util/debugger_macros.cc \
test/core/util/grpc_profiler.cc \
+ test/core/util/histogram.cc \
test/core/util/memory_counters.cc \
test/core/util/mock_endpoint.cc \
test/core/util/parse_hexstring.cc \
@@ -4591,7 +4591,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc/support/avl.h \
include/grpc/support/cmdline.h \
include/grpc/support/cpu.h \
- include/grpc/support/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
@@ -5079,7 +5078,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc/support/avl.h \
include/grpc/support/cmdline.h \
include/grpc/support/cpu.h \
- include/grpc/support/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
@@ -5801,7 +5799,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc/support/avl.h \
include/grpc/support/cmdline.h \
include/grpc/support/cpu.h \
- include/grpc/support/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
@@ -10095,38 +10092,6 @@ endif
endif
-GPR_HISTOGRAM_TEST_SRC = \
- test/core/support/histogram_test.cc \
-
-GPR_HISTOGRAM_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_HISTOGRAM_TEST_SRC))))
-ifeq ($(NO_SECURE),true)
-
-# You can't build secure targets if you don't have OpenSSL.
-
-$(BINDIR)/$(CONFIG)/gpr_histogram_test: openssl_dep_error
-
-else
-
-
-
-$(BINDIR)/$(CONFIG)/gpr_histogram_test: $(GPR_HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
- $(E) "[LD] Linking $@"
- $(Q) mkdir -p `dirname $@`
- $(Q) $(LD) $(LDFLAGS) $(GPR_HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_histogram_test
-
-endif
-
-$(OBJDIR)/$(CONFIG)/test/core/support/histogram_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-
-deps_gpr_histogram_test: $(GPR_HISTOGRAM_TEST_OBJS:.o=.dep)
-
-ifneq ($(NO_SECURE),true)
-ifneq ($(NO_DEPS),true)
--include $(GPR_HISTOGRAM_TEST_OBJS:.o=.dep)
-endif
-endif
-
-
GPR_HOST_PORT_TEST_SRC = \
test/core/support/host_port_test.cc \
@@ -11157,6 +11122,38 @@ endif
endif
+HISTOGRAM_TEST_SRC = \
+ test/core/util/histogram_test.cc \
+
+HISTOGRAM_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HISTOGRAM_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/histogram_test: openssl_dep_error
+
+else
+
+
+
+$(BINDIR)/$(CONFIG)/histogram_test: $(HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LD) $(LDFLAGS) $(HISTOGRAM_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/histogram_test
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/util/histogram_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_histogram_test: $(HISTOGRAM_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(HISTOGRAM_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
HPACK_PARSER_FUZZER_TEST_SRC = \
test/core/transport/chttp2/hpack_parser_fuzzer_test.cc \
diff --git a/build.yaml b/build.yaml
index 0908f7efd2..40c37dc53f 100644
--- a/build.yaml
+++ b/build.yaml
@@ -41,7 +41,6 @@ filegroups:
- src/core/lib/support/env_posix.cc
- src/core/lib/support/env_windows.cc
- src/core/lib/support/fork.cc
- - src/core/lib/support/histogram.cc
- src/core/lib/support/host_port.cc
- src/core/lib/support/log.cc
- src/core/lib/support/log_android.cc
@@ -83,7 +82,6 @@ filegroups:
- include/grpc/support/avl.h
- include/grpc/support/cmdline.h
- include/grpc/support/cpu.h
- - include/grpc/support/histogram.h
- include/grpc/support/host_port.h
- include/grpc/support/log.h
- include/grpc/support/log_windows.h
@@ -714,6 +712,7 @@ filegroups:
- test/core/iomgr/endpoint_tests.h
- test/core/util/debugger_macros.h
- test/core/util/grpc_profiler.h
+ - test/core/util/histogram.h
- test/core/util/memory_counters.h
- test/core/util/mock_endpoint.h
- test/core/util/parse_hexstring.h
@@ -731,6 +730,7 @@ filegroups:
- test/core/iomgr/endpoint_tests.cc
- test/core/util/debugger_macros.cc
- test/core/util/grpc_profiler.cc
+ - test/core/util/histogram.cc
- test/core/util/memory_counters.cc
- test/core/util/mock_endpoint.cc
- test/core/util/parse_hexstring.cc
@@ -2196,15 +2196,6 @@ targets:
- gpr_test_util
- gpr
uses_polling: false
-- name: gpr_histogram_test
- build: test
- language: c
- src:
- - test/core/support/histogram_test.cc
- deps:
- - gpr_test_util
- - gpr
- uses_polling: false
- name: gpr_host_port_test
build: test
language: c
@@ -2553,6 +2544,15 @@ targets:
platforms:
- linux
secure: true
+- name: histogram_test
+ build: test
+ language: c
+ src:
+ - test/core/util/histogram_test.cc
+ deps:
+ - grpc_test_util
+ - gpr
+ uses_polling: false
- name: hpack_parser_fuzzer_test
build: fuzzer
language: c
diff --git a/config.m4 b/config.m4
index 6fe897f4d5..c026b83f35 100644
--- a/config.m4
+++ b/config.m4
@@ -54,7 +54,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/support/env_posix.cc \
src/core/lib/support/env_windows.cc \
src/core/lib/support/fork.cc \
- src/core/lib/support/histogram.cc \
src/core/lib/support/host_port.cc \
src/core/lib/support/log.cc \
src/core/lib/support/log_android.cc \
diff --git a/config.w32 b/config.w32
index c2a4327c72..cd3a16a465 100644
--- a/config.w32
+++ b/config.w32
@@ -31,7 +31,6 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\support\\env_posix.cc " +
"src\\core\\lib\\support\\env_windows.cc " +
"src\\core\\lib\\support\\fork.cc " +
- "src\\core\\lib\\support\\histogram.cc " +
"src\\core\\lib\\support\\host_port.cc " +
"src\\core\\lib\\support\\log.cc " +
"src\\core\\lib\\support\\log_android.cc " +
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index 82dda2017f..39b848414a 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -113,7 +113,6 @@ Pod::Spec.new do |s|
'include/grpc/support/avl.h',
'include/grpc/support/cmdline.h',
'include/grpc/support/cpu.h',
- 'include/grpc/support/histogram.h',
'include/grpc/support/host_port.h',
'include/grpc/support/log.h',
'include/grpc/support/log_windows.h',
@@ -223,7 +222,6 @@ Pod::Spec.new do |s|
'src/core/lib/support/env_posix.cc',
'src/core/lib/support/env_windows.cc',
'src/core/lib/support/fork.cc',
- 'src/core/lib/support/histogram.cc',
'src/core/lib/support/host_port.cc',
'src/core/lib/support/log.cc',
'src/core/lib/support/log_android.cc',
diff --git a/grpc.def b/grpc.def
index 07c0b3e928..d4a18ccefc 100644
--- a/grpc.def
+++ b/grpc.def
@@ -200,21 +200,6 @@ EXPORTS
gpr_cmdline_usage_string
gpr_cpu_num_cores
gpr_cpu_current_cpu
- gpr_histogram_create
- gpr_histogram_destroy
- gpr_histogram_add
- gpr_histogram_merge
- gpr_histogram_percentile
- gpr_histogram_mean
- gpr_histogram_stddev
- gpr_histogram_variance
- gpr_histogram_maximum
- gpr_histogram_minimum
- gpr_histogram_count
- gpr_histogram_sum
- gpr_histogram_sum_of_squares
- gpr_histogram_get_contents
- gpr_histogram_merge_contents
gpr_join_host_port
gpr_split_host_port
gpr_log_severity_string
diff --git a/grpc.gemspec b/grpc.gemspec
index e553b770e4..d185995261 100644
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -52,7 +52,6 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/support/avl.h )
s.files += %w( include/grpc/support/cmdline.h )
s.files += %w( include/grpc/support/cpu.h )
- s.files += %w( include/grpc/support/histogram.h )
s.files += %w( include/grpc/support/host_port.h )
s.files += %w( include/grpc/support/log.h )
s.files += %w( include/grpc/support/log_windows.h )
@@ -117,7 +116,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/support/env_posix.cc )
s.files += %w( src/core/lib/support/env_windows.cc )
s.files += %w( src/core/lib/support/fork.cc )
- s.files += %w( src/core/lib/support/histogram.cc )
s.files += %w( src/core/lib/support/host_port.cc )
s.files += %w( src/core/lib/support/log.cc )
s.files += %w( src/core/lib/support/log_android.cc )
diff --git a/grpc.gyp b/grpc.gyp
index f2033b47b0..4ceb480282 100644
--- a/grpc.gyp
+++ b/grpc.gyp
@@ -173,7 +173,6 @@
'src/core/lib/support/env_posix.cc',
'src/core/lib/support/env_windows.cc',
'src/core/lib/support/fork.cc',
- 'src/core/lib/support/histogram.cc',
'src/core/lib/support/host_port.cc',
'src/core/lib/support/log.cc',
'src/core/lib/support/log_android.cc',
@@ -506,6 +505,7 @@
'test/core/iomgr/endpoint_tests.cc',
'test/core/util/debugger_macros.cc',
'test/core/util/grpc_profiler.cc',
+ 'test/core/util/histogram.cc',
'test/core/util/memory_counters.cc',
'test/core/util/mock_endpoint.cc',
'test/core/util/parse_hexstring.cc',
@@ -716,6 +716,7 @@
'test/core/iomgr/endpoint_tests.cc',
'test/core/util/debugger_macros.cc',
'test/core/util/grpc_profiler.cc',
+ 'test/core/util/histogram.cc',
'test/core/util/memory_counters.cc',
'test/core/util/mock_endpoint.cc',
'test/core/util/parse_hexstring.cc',
diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap
index 0faa448b70..67136cba8a 100644
--- a/include/grpc/module.modulemap
+++ b/include/grpc/module.modulemap
@@ -7,7 +7,6 @@ framework module grpc {
header "support/avl.h"
header "support/cmdline.h"
header "support/cpu.h"
- header "support/histogram.h"
header "support/host_port.h"
header "support/log.h"
header "support/log_windows.h"
diff --git a/include/grpc/support/histogram.h b/include/grpc/support/histogram.h
deleted file mode 100644
index d2794d847e..0000000000
--- a/include/grpc/support/histogram.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- *
- * Copyright 2015 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef GRPC_SUPPORT_HISTOGRAM_H
-#define GRPC_SUPPORT_HISTOGRAM_H
-
-#include <grpc/support/port_platform.h>
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct gpr_histogram gpr_histogram;
-
-GPRAPI gpr_histogram* gpr_histogram_create(double resolution,
- double max_bucket_start);
-GPRAPI void gpr_histogram_destroy(gpr_histogram* h);
-GPRAPI void gpr_histogram_add(gpr_histogram* h, double x);
-
-/** The following merges the second histogram into the first. It only works
- if they have the same buckets and resolution. Returns 0 on failure, 1
- on success */
-GPRAPI int gpr_histogram_merge(gpr_histogram* dst, const gpr_histogram* src);
-
-GPRAPI double gpr_histogram_percentile(gpr_histogram* histogram,
- double percentile);
-GPRAPI double gpr_histogram_mean(gpr_histogram* histogram);
-GPRAPI double gpr_histogram_stddev(gpr_histogram* histogram);
-GPRAPI double gpr_histogram_variance(gpr_histogram* histogram);
-GPRAPI double gpr_histogram_maximum(gpr_histogram* histogram);
-GPRAPI double gpr_histogram_minimum(gpr_histogram* histogram);
-GPRAPI double gpr_histogram_count(gpr_histogram* histogram);
-GPRAPI double gpr_histogram_sum(gpr_histogram* histogram);
-GPRAPI double gpr_histogram_sum_of_squares(gpr_histogram* histogram);
-
-GPRAPI const uint32_t* gpr_histogram_get_contents(gpr_histogram* histogram,
- size_t* count);
-GPRAPI void gpr_histogram_merge_contents(gpr_histogram* histogram,
- const uint32_t* data,
- size_t data_count, double min_seen,
- double max_seen, double sum,
- double sum_of_squares, double count);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GRPC_SUPPORT_HISTOGRAM_H */
diff --git a/package.xml b/package.xml
index 435fb4c2c2..b4d8c88693 100644
--- a/package.xml
+++ b/package.xml
@@ -64,7 +64,6 @@
<file baseinstalldir="/" name="include/grpc/support/avl.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/cmdline.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/cpu.h" role="src" />
- <file baseinstalldir="/" name="include/grpc/support/histogram.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/host_port.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/log.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/log_windows.h" role="src" />
@@ -129,7 +128,6 @@
<file baseinstalldir="/" name="src/core/lib/support/env_posix.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/env_windows.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/fork.cc" role="src" />
- <file baseinstalldir="/" name="src/core/lib/support/histogram.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/host_port.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/log.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/log_android.cc" role="src" />
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index 56d6ebd842..d2a68f0902 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -30,7 +30,6 @@ CORE_SOURCE_FILES = [
'src/core/lib/support/env_posix.cc',
'src/core/lib/support/env_windows.cc',
'src/core/lib/support/fork.cc',
- 'src/core/lib/support/histogram.cc',
'src/core/lib/support/host_port.cc',
'src/core/lib/support/log.cc',
'src/core/lib/support/log_android.cc',
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
index 648d515003..56f1d4c93f 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
@@ -223,21 +223,6 @@ gpr_cmdline_destroy_type gpr_cmdline_destroy_import;
gpr_cmdline_usage_string_type gpr_cmdline_usage_string_import;
gpr_cpu_num_cores_type gpr_cpu_num_cores_import;
gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import;
-gpr_histogram_create_type gpr_histogram_create_import;
-gpr_histogram_destroy_type gpr_histogram_destroy_import;
-gpr_histogram_add_type gpr_histogram_add_import;
-gpr_histogram_merge_type gpr_histogram_merge_import;
-gpr_histogram_percentile_type gpr_histogram_percentile_import;
-gpr_histogram_mean_type gpr_histogram_mean_import;
-gpr_histogram_stddev_type gpr_histogram_stddev_import;
-gpr_histogram_variance_type gpr_histogram_variance_import;
-gpr_histogram_maximum_type gpr_histogram_maximum_import;
-gpr_histogram_minimum_type gpr_histogram_minimum_import;
-gpr_histogram_count_type gpr_histogram_count_import;
-gpr_histogram_sum_type gpr_histogram_sum_import;
-gpr_histogram_sum_of_squares_type gpr_histogram_sum_of_squares_import;
-gpr_histogram_get_contents_type gpr_histogram_get_contents_import;
-gpr_histogram_merge_contents_type gpr_histogram_merge_contents_import;
gpr_join_host_port_type gpr_join_host_port_import;
gpr_split_host_port_type gpr_split_host_port_import;
gpr_log_severity_string_type gpr_log_severity_string_import;
@@ -510,21 +495,6 @@ void grpc_rb_load_imports(HMODULE library) {
gpr_cmdline_usage_string_import = (gpr_cmdline_usage_string_type) GetProcAddress(library, "gpr_cmdline_usage_string");
gpr_cpu_num_cores_import = (gpr_cpu_num_cores_type) GetProcAddress(library, "gpr_cpu_num_cores");
gpr_cpu_current_cpu_import = (gpr_cpu_current_cpu_type) GetProcAddress(library, "gpr_cpu_current_cpu");
- gpr_histogram_create_import = (gpr_histogram_create_type) GetProcAddress(library, "gpr_histogram_create");
- gpr_histogram_destroy_import = (gpr_histogram_destroy_type) GetProcAddress(library, "gpr_histogram_destroy");
- gpr_histogram_add_import = (gpr_histogram_add_type) GetProcAddress(library, "gpr_histogram_add");
- gpr_histogram_merge_import = (gpr_histogram_merge_type) GetProcAddress(library, "gpr_histogram_merge");
- gpr_histogram_percentile_import = (gpr_histogram_percentile_type) GetProcAddress(library, "gpr_histogram_percentile");
- gpr_histogram_mean_import = (gpr_histogram_mean_type) GetProcAddress(library, "gpr_histogram_mean");
- gpr_histogram_stddev_import = (gpr_histogram_stddev_type) GetProcAddress(library, "gpr_histogram_stddev");
- gpr_histogram_variance_import = (gpr_histogram_variance_type) GetProcAddress(library, "gpr_histogram_variance");
- gpr_histogram_maximum_import = (gpr_histogram_maximum_type) GetProcAddress(library, "gpr_histogram_maximum");
- gpr_histogram_minimum_import = (gpr_histogram_minimum_type) GetProcAddress(library, "gpr_histogram_minimum");
- gpr_histogram_count_import = (gpr_histogram_count_type) GetProcAddress(library, "gpr_histogram_count");
- gpr_histogram_sum_import = (gpr_histogram_sum_type) GetProcAddress(library, "gpr_histogram_sum");
- gpr_histogram_sum_of_squares_import = (gpr_histogram_sum_of_squares_type) GetProcAddress(library, "gpr_histogram_sum_of_squares");
- gpr_histogram_get_contents_import = (gpr_histogram_get_contents_type) GetProcAddress(library, "gpr_histogram_get_contents");
- gpr_histogram_merge_contents_import = (gpr_histogram_merge_contents_type) GetProcAddress(library, "gpr_histogram_merge_contents");
gpr_join_host_port_import = (gpr_join_host_port_type) GetProcAddress(library, "gpr_join_host_port");
gpr_split_host_port_import = (gpr_split_host_port_type) GetProcAddress(library, "gpr_split_host_port");
gpr_log_severity_string_import = (gpr_log_severity_string_type) GetProcAddress(library, "gpr_log_severity_string");
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
index c2698d16ea..62223fda5b 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
@@ -36,7 +36,6 @@
#include <grpc/support/avl.h>
#include <grpc/support/cmdline.h>
#include <grpc/support/cpu.h>
-#include <grpc/support/histogram.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/log_windows.h>
@@ -649,51 +648,6 @@ extern gpr_cpu_num_cores_type gpr_cpu_num_cores_import;
typedef unsigned(*gpr_cpu_current_cpu_type)(void);
extern gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import;
#define gpr_cpu_current_cpu gpr_cpu_current_cpu_import
-typedef gpr_histogram*(*gpr_histogram_create_type)(double resolution, double max_bucket_start);
-extern gpr_histogram_create_type gpr_histogram_create_import;
-#define gpr_histogram_create gpr_histogram_create_import
-typedef void(*gpr_histogram_destroy_type)(gpr_histogram* h);
-extern gpr_histogram_destroy_type gpr_histogram_destroy_import;
-#define gpr_histogram_destroy gpr_histogram_destroy_import
-typedef void(*gpr_histogram_add_type)(gpr_histogram* h, double x);
-extern gpr_histogram_add_type gpr_histogram_add_import;
-#define gpr_histogram_add gpr_histogram_add_import
-typedef int(*gpr_histogram_merge_type)(gpr_histogram* dst, const gpr_histogram* src);
-extern gpr_histogram_merge_type gpr_histogram_merge_import;
-#define gpr_histogram_merge gpr_histogram_merge_import
-typedef double(*gpr_histogram_percentile_type)(gpr_histogram* histogram, double percentile);
-extern gpr_histogram_percentile_type gpr_histogram_percentile_import;
-#define gpr_histogram_percentile gpr_histogram_percentile_import
-typedef double(*gpr_histogram_mean_type)(gpr_histogram* histogram);
-extern gpr_histogram_mean_type gpr_histogram_mean_import;
-#define gpr_histogram_mean gpr_histogram_mean_import
-typedef double(*gpr_histogram_stddev_type)(gpr_histogram* histogram);
-extern gpr_histogram_stddev_type gpr_histogram_stddev_import;
-#define gpr_histogram_stddev gpr_histogram_stddev_import
-typedef double(*gpr_histogram_variance_type)(gpr_histogram* histogram);
-extern gpr_histogram_variance_type gpr_histogram_variance_import;
-#define gpr_histogram_variance gpr_histogram_variance_import
-typedef double(*gpr_histogram_maximum_type)(gpr_histogram* histogram);
-extern gpr_histogram_maximum_type gpr_histogram_maximum_import;
-#define gpr_histogram_maximum gpr_histogram_maximum_import
-typedef double(*gpr_histogram_minimum_type)(gpr_histogram* histogram);
-extern gpr_histogram_minimum_type gpr_histogram_minimum_import;
-#define gpr_histogram_minimum gpr_histogram_minimum_import
-typedef double(*gpr_histogram_count_type)(gpr_histogram* histogram);
-extern gpr_histogram_count_type gpr_histogram_count_import;
-#define gpr_histogram_count gpr_histogram_count_import
-typedef double(*gpr_histogram_sum_type)(gpr_histogram* histogram);
-extern gpr_histogram_sum_type gpr_histogram_sum_import;
-#define gpr_histogram_sum gpr_histogram_sum_import
-typedef double(*gpr_histogram_sum_of_squares_type)(gpr_histogram* histogram);
-extern gpr_histogram_sum_of_squares_type gpr_histogram_sum_of_squares_import;
-#define gpr_histogram_sum_of_squares gpr_histogram_sum_of_squares_import
-typedef const uint32_t*(*gpr_histogram_get_contents_type)(gpr_histogram* histogram, size_t* count);
-extern gpr_histogram_get_contents_type gpr_histogram_get_contents_import;
-#define gpr_histogram_get_contents gpr_histogram_get_contents_import
-typedef void(*gpr_histogram_merge_contents_type)(gpr_histogram* histogram, const uint32_t* data, size_t data_count, double min_seen, double max_seen, double sum, double sum_of_squares, double count);
-extern gpr_histogram_merge_contents_type gpr_histogram_merge_contents_import;
-#define gpr_histogram_merge_contents gpr_histogram_merge_contents_import
typedef int(*gpr_join_host_port_type)(char** out, const char* host, int port);
extern gpr_join_host_port_type gpr_join_host_port_import;
#define gpr_join_host_port gpr_join_host_port_import
diff --git a/test/core/fling/client.cc b/test/core/fling/client.cc
index 544b66d480..69fb6dc7c7 100644
--- a/test/core/fling/client.cc
+++ b/test/core/fling/client.cc
@@ -22,15 +22,15 @@
#include <string.h>
#include <grpc/support/cmdline.h>
-#include <grpc/support/histogram.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
#include "src/core/lib/profiling/timers.h"
#include "test/core/util/grpc_profiler.h"
+#include "test/core/util/histogram.h"
#include "test/core/util/test_config.h"
-static gpr_histogram* histogram;
+static grpc_histogram* histogram;
static grpc_byte_buffer* the_buffer;
static grpc_channel* channel;
static grpc_completion_queue* cq;
@@ -195,7 +195,7 @@ int main(int argc, char** argv) {
channel = grpc_insecure_channel_create(target, nullptr, nullptr);
cq = grpc_completion_queue_create_for_next(nullptr);
the_buffer = grpc_raw_byte_buffer_create(&slice, (size_t)payload_size);
- histogram = gpr_histogram_create(0.01, 60e9);
+ histogram = grpc_histogram_create(0.01, 60e9);
sc.init();
@@ -213,7 +213,7 @@ int main(int argc, char** argv) {
start = now();
sc.do_one_step();
stop = now();
- gpr_histogram_add(histogram, stop - start);
+ grpc_histogram_add(histogram, stop - start);
}
grpc_profiler_stop();
@@ -232,11 +232,11 @@ int main(int argc, char** argv) {
grpc_slice_unref(slice);
gpr_log(GPR_INFO, "latency (50/95/99/99.9): %f/%f/%f/%f",
- gpr_histogram_percentile(histogram, 50),
- gpr_histogram_percentile(histogram, 95),
- gpr_histogram_percentile(histogram, 99),
- gpr_histogram_percentile(histogram, 99.9));
- gpr_histogram_destroy(histogram);
+ grpc_histogram_percentile(histogram, 50),
+ grpc_histogram_percentile(histogram, 95),
+ grpc_histogram_percentile(histogram, 99),
+ grpc_histogram_percentile(histogram, 99.9));
+ grpc_histogram_destroy(histogram);
grpc_shutdown();
diff --git a/test/core/network_benchmarks/low_level_ping_pong.cc b/test/core/network_benchmarks/low_level_ping_pong.cc
index 687395d916..2ae9a45d7c 100644
--- a/test/core/network_benchmarks/low_level_ping_pong.cc
+++ b/test/core/network_benchmarks/low_level_ping_pong.cc
@@ -36,13 +36,13 @@
#include <grpc/support/alloc.h>
#include <grpc/support/cmdline.h>
-#include <grpc/support/histogram.h>
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
+#include "test/core/util/histogram.h"
typedef struct fd_pair {
int read_fd;
@@ -275,14 +275,14 @@ static void server_thread_wrap(void* arg) {
server_thread(args);
}
-static void print_histogram(gpr_histogram* histogram) {
+static void print_histogram(grpc_histogram* histogram) {
/* TODO(klempner): Print more detailed information, such as detailed histogram
buckets */
gpr_log(GPR_INFO, "latency (50/95/99/99.9): %f/%f/%f/%f",
- gpr_histogram_percentile(histogram, 50),
- gpr_histogram_percentile(histogram, 95),
- gpr_histogram_percentile(histogram, 99),
- gpr_histogram_percentile(histogram, 99.9));
+ grpc_histogram_percentile(histogram, 50),
+ grpc_histogram_percentile(histogram, 95),
+ grpc_histogram_percentile(histogram, 99),
+ grpc_histogram_percentile(histogram, 99.9));
}
static double now(void) {
@@ -293,7 +293,7 @@ static double now(void) {
static void client_thread(thread_args* args) {
char* buf = static_cast<char*>(gpr_malloc(args->msg_size * sizeof(char)));
memset(buf, 0, args->msg_size * sizeof(char));
- gpr_histogram* histogram = gpr_histogram_create(0.01, 60e9);
+ grpc_histogram* histogram = grpc_histogram_create(0.01, 60e9);
double start_time;
double end_time;
double interval;
@@ -316,13 +316,13 @@ static void client_thread(thread_args* args) {
end_time = now();
if (i > kNumIters / 2) {
interval = end_time - start_time;
- gpr_histogram_add(histogram, interval);
+ grpc_histogram_add(histogram, interval);
}
}
print_histogram(histogram);
error:
gpr_free(buf);
- gpr_histogram_destroy(histogram);
+ grpc_histogram_destroy(histogram);
}
/* This roughly matches tcp_server's create_listening_socket */
diff --git a/test/core/support/BUILD b/test/core/support/BUILD
index 32b64d4b8e..4372b49b54 100644
--- a/test/core/support/BUILD
+++ b/test/core/support/BUILD
@@ -69,16 +69,6 @@ grpc_cc_test(
)
grpc_cc_test(
- name = "histogram_test",
- srcs = ["histogram_test.cc"],
- language = "C++",
- deps = [
- "//:gpr",
- "//test/core/util:gpr_test_util",
- ],
-)
-
-grpc_cc_test(
name = "host_port_test",
srcs = ["host_port_test.cc"],
language = "C++",
diff --git a/test/core/support/histogram_test.cc b/test/core/support/histogram_test.cc
deleted file mode 100644
index 86b7d599e6..0000000000
--- a/test/core/support/histogram_test.cc
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- *
- * Copyright 2015 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <grpc/support/histogram.h>
-#include <grpc/support/log.h>
-
-#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x);
-
-static void test_no_op(void) {
- gpr_histogram_destroy(gpr_histogram_create(0.01, 60e9));
-}
-
-static void expect_percentile(gpr_histogram* h, double percentile,
- double min_expect, double max_expect) {
- double got = gpr_histogram_percentile(h, percentile);
- gpr_log(GPR_INFO, "@%f%%, expect %f <= %f <= %f", percentile, min_expect, got,
- max_expect);
- GPR_ASSERT(min_expect <= got);
- GPR_ASSERT(got <= max_expect);
-}
-
-static void test_simple(void) {
- gpr_histogram* h;
-
- LOG_TEST("test_simple");
-
- h = gpr_histogram_create(0.01, 60e9);
- gpr_histogram_add(h, 10000);
- gpr_histogram_add(h, 10000);
- gpr_histogram_add(h, 11000);
- gpr_histogram_add(h, 11000);
-
- expect_percentile(h, 50, 10001, 10999);
- GPR_ASSERT(gpr_histogram_mean(h) == 10500);
-
- gpr_histogram_destroy(h);
-}
-
-static void test_percentile(void) {
- gpr_histogram* h;
- double last;
- double i;
- double cur;
-
- LOG_TEST("test_percentile");
-
- h = gpr_histogram_create(0.05, 1e9);
- gpr_histogram_add(h, 2.5);
- gpr_histogram_add(h, 2.5);
- gpr_histogram_add(h, 8);
- gpr_histogram_add(h, 4);
-
- GPR_ASSERT(gpr_histogram_count(h) == 4);
- GPR_ASSERT(gpr_histogram_minimum(h) == 2.5);
- GPR_ASSERT(gpr_histogram_maximum(h) == 8);
- GPR_ASSERT(gpr_histogram_sum(h) == 17);
- GPR_ASSERT(gpr_histogram_sum_of_squares(h) == 92.5);
- GPR_ASSERT(gpr_histogram_mean(h) == 4.25);
- GPR_ASSERT(gpr_histogram_variance(h) == 5.0625);
- GPR_ASSERT(gpr_histogram_stddev(h) == 2.25);
-
- expect_percentile(h, -10, 2.5, 2.5);
- expect_percentile(h, 0, 2.5, 2.5);
- expect_percentile(h, 12.5, 2.5, 2.5);
- expect_percentile(h, 25, 2.5, 2.5);
- expect_percentile(h, 37.5, 2.5, 2.8);
- expect_percentile(h, 50, 3.0, 3.5);
- expect_percentile(h, 62.5, 3.5, 4.5);
- expect_percentile(h, 75, 5, 7.9);
- expect_percentile(h, 100, 8, 8);
- expect_percentile(h, 110, 8, 8);
-
- /* test monotonicity */
- last = 0.0;
- for (i = 0; i < 100.0; i += 0.01) {
- cur = gpr_histogram_percentile(h, i);
- GPR_ASSERT(cur >= last);
- last = cur;
- }
-
- gpr_histogram_destroy(h);
-}
-
-static void test_merge(void) {
- gpr_histogram *h1, *h2;
- double last;
- double i;
- double cur;
-
- LOG_TEST("test_merge");
-
- h1 = gpr_histogram_create(0.05, 1e9);
- gpr_histogram_add(h1, 2.5);
- gpr_histogram_add(h1, 2.5);
- gpr_histogram_add(h1, 8);
- gpr_histogram_add(h1, 4);
-
- h2 = gpr_histogram_create(0.01, 1e9);
- GPR_ASSERT(gpr_histogram_merge(h1, h2) == 0);
- gpr_histogram_destroy(h2);
-
- h2 = gpr_histogram_create(0.05, 1e10);
- GPR_ASSERT(gpr_histogram_merge(h1, h2) == 0);
- gpr_histogram_destroy(h2);
-
- h2 = gpr_histogram_create(0.05, 1e9);
- GPR_ASSERT(gpr_histogram_merge(h1, h2) == 1);
- GPR_ASSERT(gpr_histogram_count(h1) == 4);
- GPR_ASSERT(gpr_histogram_minimum(h1) == 2.5);
- GPR_ASSERT(gpr_histogram_maximum(h1) == 8);
- GPR_ASSERT(gpr_histogram_sum(h1) == 17);
- GPR_ASSERT(gpr_histogram_sum_of_squares(h1) == 92.5);
- GPR_ASSERT(gpr_histogram_mean(h1) == 4.25);
- GPR_ASSERT(gpr_histogram_variance(h1) == 5.0625);
- GPR_ASSERT(gpr_histogram_stddev(h1) == 2.25);
- gpr_histogram_destroy(h2);
-
- h2 = gpr_histogram_create(0.05, 1e9);
- gpr_histogram_add(h2, 7.0);
- gpr_histogram_add(h2, 17.0);
- gpr_histogram_add(h2, 1.0);
- GPR_ASSERT(gpr_histogram_merge(h1, h2) == 1);
- GPR_ASSERT(gpr_histogram_count(h1) == 7);
- GPR_ASSERT(gpr_histogram_minimum(h1) == 1.0);
- GPR_ASSERT(gpr_histogram_maximum(h1) == 17.0);
- GPR_ASSERT(gpr_histogram_sum(h1) == 42.0);
- GPR_ASSERT(gpr_histogram_sum_of_squares(h1) == 431.5);
- GPR_ASSERT(gpr_histogram_mean(h1) == 6.0);
-
- /* test monotonicity */
- last = 0.0;
- for (i = 0; i < 100.0; i += 0.01) {
- cur = gpr_histogram_percentile(h1, i);
- GPR_ASSERT(cur >= last);
- last = cur;
- }
-
- gpr_histogram_destroy(h1);
- gpr_histogram_destroy(h2);
-}
-
-int main(void) {
- test_no_op();
- test_simple();
- test_percentile();
- test_merge();
- return 0;
-}
diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c
index 33dc70a685..8d2384ba61 100644
--- a/test/core/surface/public_headers_must_be_c89.c
+++ b/test/core/surface/public_headers_must_be_c89.c
@@ -50,7 +50,6 @@
#include <grpc/support/avl.h>
#include <grpc/support/cmdline.h>
#include <grpc/support/cpu.h>
-#include <grpc/support/histogram.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@@ -266,21 +265,6 @@ int main(int argc, char **argv) {
printf("%lx", (unsigned long) gpr_cmdline_usage_string);
printf("%lx", (unsigned long) gpr_cpu_num_cores);
printf("%lx", (unsigned long) gpr_cpu_current_cpu);
- printf("%lx", (unsigned long) gpr_histogram_create);
- printf("%lx", (unsigned long) gpr_histogram_destroy);
- printf("%lx", (unsigned long) gpr_histogram_add);
- printf("%lx", (unsigned long) gpr_histogram_merge);
- printf("%lx", (unsigned long) gpr_histogram_percentile);
- printf("%lx", (unsigned long) gpr_histogram_mean);
- printf("%lx", (unsigned long) gpr_histogram_stddev);
- printf("%lx", (unsigned long) gpr_histogram_variance);
- printf("%lx", (unsigned long) gpr_histogram_maximum);
- printf("%lx", (unsigned long) gpr_histogram_minimum);
- printf("%lx", (unsigned long) gpr_histogram_count);
- printf("%lx", (unsigned long) gpr_histogram_sum);
- printf("%lx", (unsigned long) gpr_histogram_sum_of_squares);
- printf("%lx", (unsigned long) gpr_histogram_get_contents);
- printf("%lx", (unsigned long) gpr_histogram_merge_contents);
printf("%lx", (unsigned long) gpr_join_host_port);
printf("%lx", (unsigned long) gpr_split_host_port);
printf("%lx", (unsigned long) gpr_log_severity_string);
diff --git a/test/core/util/BUILD b/test/core/util/BUILD
index 6443553466..268547f6c9 100644
--- a/test/core/util/BUILD
+++ b/test/core/util/BUILD
@@ -16,7 +16,10 @@ load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_c
licenses(["notice"]) # Apache v2
-grpc_package(name = "test/core/util", visibility = "public")
+grpc_package(
+ name = "test/core/util",
+ visibility = "public",
+)
grpc_cc_library(
name = "gpr_test_util",
@@ -49,6 +52,7 @@ grpc_cc_library(
name = "grpc_test_util_base",
srcs = [
"grpc_profiler.cc",
+ "histogram.cc",
"mock_endpoint.cc",
"parse_hexstring.cc",
"passthru_endpoint.cc",
@@ -62,6 +66,7 @@ grpc_cc_library(
],
hdrs = [
"grpc_profiler.h",
+ "histogram.h",
"mock_endpoint.h",
"parse_hexstring.h",
"passthru_endpoint.h",
@@ -76,8 +81,8 @@ grpc_cc_library(
language = "C++",
deps = [
":gpr_test_util",
+ ":grpc_debugger_macros",
"//:grpc_common",
- ":grpc_debugger_macros"
],
)
@@ -107,13 +112,23 @@ grpc_cc_library(
name = "fuzzer_corpus_test",
testonly = 1,
srcs = ["fuzzer_corpus_test.cc"],
+ external_deps = [
+ "gtest",
+ "gflags",
+ ],
deps = [
":gpr_test_util",
"//:grpc",
],
- external_deps = [
- "gtest",
- "gflags",
+)
+
+grpc_cc_test(
+ name = "histogram_test",
+ srcs = ["histogram_test.cc"],
+ language = "C++",
+ deps = [
+ ":grpc_test_util",
+ "//:gpr",
],
)
diff --git a/src/core/lib/support/histogram.cc b/test/core/util/histogram.cc
index 73c821a28b..2f916f831d 100644
--- a/src/core/lib/support/histogram.cc
+++ b/test/core/util/histogram.cc
@@ -16,8 +16,6 @@
*
*/
-#include <grpc/support/histogram.h>
-
#include <math.h>
#include <stddef.h>
#include <string.h>
@@ -27,12 +25,14 @@
#include <grpc/support/port_platform.h>
#include <grpc/support/useful.h>
+#include "test/core/util/histogram.h"
+
/* Histograms are stored with exponentially increasing bucket sizes.
The first bucket is [0, m) where m = 1 + resolution
Bucket n (n>=1) contains [m**n, m**(n+1))
There are sufficient buckets to reach max_bucket_start */
-struct gpr_histogram {
+struct grpc_histogram {
/* Sum of all values seen so far */
double sum;
/* Sum of squares of all values seen so far */
@@ -55,25 +55,25 @@ struct gpr_histogram {
};
/* determine a bucket index given a value - does no bounds checking */
-static size_t bucket_for_unchecked(gpr_histogram* h, double x) {
+static size_t bucket_for_unchecked(grpc_histogram* h, double x) {
return (size_t)(log(x) * h->one_on_log_multiplier);
}
/* bounds checked version of the above */
-static size_t bucket_for(gpr_histogram* h, double x) {
+static size_t bucket_for(grpc_histogram* h, double x) {
size_t bucket = bucket_for_unchecked(h, GPR_CLAMP(x, 1.0, h->max_possible));
GPR_ASSERT(bucket < h->num_buckets);
return bucket;
}
/* at what value does a bucket start? */
-static double bucket_start(gpr_histogram* h, double x) {
+static double bucket_start(grpc_histogram* h, double x) {
return pow(h->multiplier, x);
}
-gpr_histogram* gpr_histogram_create(double resolution,
- double max_bucket_start) {
- gpr_histogram* h = (gpr_histogram*)gpr_malloc(sizeof(gpr_histogram));
+grpc_histogram* grpc_histogram_create(double resolution,
+ double max_bucket_start) {
+ grpc_histogram* h = (grpc_histogram*)gpr_malloc(sizeof(grpc_histogram));
GPR_ASSERT(resolution > 0.0);
GPR_ASSERT(max_bucket_start > resolution);
h->sum = 0.0;
@@ -91,12 +91,12 @@ gpr_histogram* gpr_histogram_create(double resolution,
return h;
}
-void gpr_histogram_destroy(gpr_histogram* h) {
+void grpc_histogram_destroy(grpc_histogram* h) {
gpr_free(h->buckets);
gpr_free(h);
}
-void gpr_histogram_add(gpr_histogram* h, double x) {
+void grpc_histogram_add(grpc_histogram* h, double x) {
h->sum += x;
h->sum_of_squares += x * x;
h->count++;
@@ -109,22 +109,22 @@ void gpr_histogram_add(gpr_histogram* h, double x) {
h->buckets[bucket_for(h, x)]++;
}
-int gpr_histogram_merge(gpr_histogram* dst, const gpr_histogram* src) {
+int grpc_histogram_merge(grpc_histogram* dst, const grpc_histogram* src) {
if ((dst->num_buckets != src->num_buckets) ||
(dst->multiplier != src->multiplier)) {
/* Fail because these histograms don't match */
return 0;
}
- gpr_histogram_merge_contents(dst, src->buckets, src->num_buckets,
- src->min_seen, src->max_seen, src->sum,
- src->sum_of_squares, src->count);
+ grpc_histogram_merge_contents(dst, src->buckets, src->num_buckets,
+ src->min_seen, src->max_seen, src->sum,
+ src->sum_of_squares, src->count);
return 1;
}
-void gpr_histogram_merge_contents(gpr_histogram* dst, const uint32_t* data,
- size_t data_count, double min_seen,
- double max_seen, double sum,
- double sum_of_squares, double count) {
+void grpc_histogram_merge_contents(grpc_histogram* dst, const uint32_t* data,
+ size_t data_count, double min_seen,
+ double max_seen, double sum,
+ double sum_of_squares, double count) {
size_t i;
GPR_ASSERT(dst->num_buckets == data_count);
dst->sum += sum;
@@ -141,7 +141,7 @@ void gpr_histogram_merge_contents(gpr_histogram* dst, const uint32_t* data,
}
}
-static double threshold_for_count_below(gpr_histogram* h, double count_below) {
+static double threshold_for_count_below(grpc_histogram* h, double count_below) {
double count_so_far;
double lower_bound;
double upper_bound;
@@ -190,38 +190,38 @@ static double threshold_for_count_below(gpr_histogram* h, double count_below) {
}
}
-double gpr_histogram_percentile(gpr_histogram* h, double percentile) {
+double grpc_histogram_percentile(grpc_histogram* h, double percentile) {
return threshold_for_count_below(h, h->count * percentile / 100.0);
}
-double gpr_histogram_mean(gpr_histogram* h) {
+double grpc_histogram_mean(grpc_histogram* h) {
GPR_ASSERT(h->count != 0);
return h->sum / h->count;
}
-double gpr_histogram_stddev(gpr_histogram* h) {
- return sqrt(gpr_histogram_variance(h));
+double grpc_histogram_stddev(grpc_histogram* h) {
+ return sqrt(grpc_histogram_variance(h));
}
-double gpr_histogram_variance(gpr_histogram* h) {
+double grpc_histogram_variance(grpc_histogram* h) {
if (h->count == 0) return 0.0;
return (h->sum_of_squares * h->count - h->sum * h->sum) /
(h->count * h->count);
}
-double gpr_histogram_maximum(gpr_histogram* h) { return h->max_seen; }
+double grpc_histogram_maximum(grpc_histogram* h) { return h->max_seen; }
-double gpr_histogram_minimum(gpr_histogram* h) { return h->min_seen; }
+double grpc_histogram_minimum(grpc_histogram* h) { return h->min_seen; }
-double gpr_histogram_count(gpr_histogram* h) { return h->count; }
+double grpc_histogram_count(grpc_histogram* h) { return h->count; }
-double gpr_histogram_sum(gpr_histogram* h) { return h->sum; }
+double grpc_histogram_sum(grpc_histogram* h) { return h->sum; }
-double gpr_histogram_sum_of_squares(gpr_histogram* h) {
+double grpc_histogram_sum_of_squares(grpc_histogram* h) {
return h->sum_of_squares;
}
-const uint32_t* gpr_histogram_get_contents(gpr_histogram* h, size_t* size) {
+const uint32_t* grpc_histogram_get_contents(grpc_histogram* h, size_t* size) {
*size = h->num_buckets;
return h->buckets;
}
diff --git a/test/core/util/histogram.h b/test/core/util/histogram.h
new file mode 100644
index 0000000000..9d4985e64f
--- /dev/null
+++ b/test/core/util/histogram.h
@@ -0,0 +1,62 @@
+/*
+ *
+ * Copyright 2015 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef GRPC_SUPPORT_HISTOGRAM_H
+#define GRPC_SUPPORT_HISTOGRAM_H
+
+#include <grpc/support/port_platform.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct grpc_histogram grpc_histogram;
+
+grpc_histogram* grpc_histogram_create(double resolution,
+ double max_bucket_start);
+void grpc_histogram_destroy(grpc_histogram* h);
+void grpc_histogram_add(grpc_histogram* h, double x);
+
+/** The following merges the second histogram into the first. It only works
+ if they have the same buckets and resolution. Returns 0 on failure, 1
+ on success */
+int grpc_histogram_merge(grpc_histogram* dst, const grpc_histogram* src);
+
+double grpc_histogram_percentile(grpc_histogram* histogram, double percentile);
+double grpc_histogram_mean(grpc_histogram* histogram);
+double grpc_histogram_stddev(grpc_histogram* histogram);
+double grpc_histogram_variance(grpc_histogram* histogram);
+double grpc_histogram_maximum(grpc_histogram* histogram);
+double grpc_histogram_minimum(grpc_histogram* histogram);
+double grpc_histogram_count(grpc_histogram* histogram);
+double grpc_histogram_sum(grpc_histogram* histogram);
+double grpc_histogram_sum_of_squares(grpc_histogram* histogram);
+
+const uint32_t* grpc_histogram_get_contents(grpc_histogram* histogram,
+ size_t* count);
+void grpc_histogram_merge_contents(grpc_histogram* histogram,
+ const uint32_t* data, size_t data_count,
+ double min_seen, double max_seen, double sum,
+ double sum_of_squares, double count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GRPC_SUPPORT_HISTOGRAM_H */
diff --git a/test/core/util/histogram_test.cc b/test/core/util/histogram_test.cc
new file mode 100644
index 0000000000..b96ac7d841
--- /dev/null
+++ b/test/core/util/histogram_test.cc
@@ -0,0 +1,163 @@
+/*
+ *
+ * Copyright 2015 gRPC authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "test/core/util/histogram.h"
+#include <grpc/support/log.h>
+
+#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x);
+
+static void test_no_op(void) {
+ grpc_histogram_destroy(grpc_histogram_create(0.01, 60e9));
+}
+
+static void expect_percentile(grpc_histogram* h, double percentile,
+ double min_expect, double max_expect) {
+ double got = grpc_histogram_percentile(h, percentile);
+ gpr_log(GPR_INFO, "@%f%%, expect %f <= %f <= %f", percentile, min_expect, got,
+ max_expect);
+ GPR_ASSERT(min_expect <= got);
+ GPR_ASSERT(got <= max_expect);
+}
+
+static void test_simple(void) {
+ grpc_histogram* h;
+
+ LOG_TEST("test_simple");
+
+ h = grpc_histogram_create(0.01, 60e9);
+ grpc_histogram_add(h, 10000);
+ grpc_histogram_add(h, 10000);
+ grpc_histogram_add(h, 11000);
+ grpc_histogram_add(h, 11000);
+
+ expect_percentile(h, 50, 10001, 10999);
+ GPR_ASSERT(grpc_histogram_mean(h) == 10500);
+
+ grpc_histogram_destroy(h);
+}
+
+static void test_percentile(void) {
+ grpc_histogram* h;
+ double last;
+ double i;
+ double cur;
+
+ LOG_TEST("test_percentile");
+
+ h = grpc_histogram_create(0.05, 1e9);
+ grpc_histogram_add(h, 2.5);
+ grpc_histogram_add(h, 2.5);
+ grpc_histogram_add(h, 8);
+ grpc_histogram_add(h, 4);
+
+ GPR_ASSERT(grpc_histogram_count(h) == 4);
+ GPR_ASSERT(grpc_histogram_minimum(h) == 2.5);
+ GPR_ASSERT(grpc_histogram_maximum(h) == 8);
+ GPR_ASSERT(grpc_histogram_sum(h) == 17);
+ GPR_ASSERT(grpc_histogram_sum_of_squares(h) == 92.5);
+ GPR_ASSERT(grpc_histogram_mean(h) == 4.25);
+ GPR_ASSERT(grpc_histogram_variance(h) == 5.0625);
+ GPR_ASSERT(grpc_histogram_stddev(h) == 2.25);
+
+ expect_percentile(h, -10, 2.5, 2.5);
+ expect_percentile(h, 0, 2.5, 2.5);
+ expect_percentile(h, 12.5, 2.5, 2.5);
+ expect_percentile(h, 25, 2.5, 2.5);
+ expect_percentile(h, 37.5, 2.5, 2.8);
+ expect_percentile(h, 50, 3.0, 3.5);
+ expect_percentile(h, 62.5, 3.5, 4.5);
+ expect_percentile(h, 75, 5, 7.9);
+ expect_percentile(h, 100, 8, 8);
+ expect_percentile(h, 110, 8, 8);
+
+ /* test monotonicity */
+ last = 0.0;
+ for (i = 0; i < 100.0; i += 0.01) {
+ cur = grpc_histogram_percentile(h, i);
+ GPR_ASSERT(cur >= last);
+ last = cur;
+ }
+
+ grpc_histogram_destroy(h);
+}
+
+static void test_merge(void) {
+ grpc_histogram *h1, *h2;
+ double last;
+ double i;
+ double cur;
+
+ LOG_TEST("test_merge");
+
+ h1 = grpc_histogram_create(0.05, 1e9);
+ grpc_histogram_add(h1, 2.5);
+ grpc_histogram_add(h1, 2.5);
+ grpc_histogram_add(h1, 8);
+ grpc_histogram_add(h1, 4);
+
+ h2 = grpc_histogram_create(0.01, 1e9);
+ GPR_ASSERT(grpc_histogram_merge(h1, h2) == 0);
+ grpc_histogram_destroy(h2);
+
+ h2 = grpc_histogram_create(0.05, 1e10);
+ GPR_ASSERT(grpc_histogram_merge(h1, h2) == 0);
+ grpc_histogram_destroy(h2);
+
+ h2 = grpc_histogram_create(0.05, 1e9);
+ GPR_ASSERT(grpc_histogram_merge(h1, h2) == 1);
+ GPR_ASSERT(grpc_histogram_count(h1) == 4);
+ GPR_ASSERT(grpc_histogram_minimum(h1) == 2.5);
+ GPR_ASSERT(grpc_histogram_maximum(h1) == 8);
+ GPR_ASSERT(grpc_histogram_sum(h1) == 17);
+ GPR_ASSERT(grpc_histogram_sum_of_squares(h1) == 92.5);
+ GPR_ASSERT(grpc_histogram_mean(h1) == 4.25);
+ GPR_ASSERT(grpc_histogram_variance(h1) == 5.0625);
+ GPR_ASSERT(grpc_histogram_stddev(h1) == 2.25);
+ grpc_histogram_destroy(h2);
+
+ h2 = grpc_histogram_create(0.05, 1e9);
+ grpc_histogram_add(h2, 7.0);
+ grpc_histogram_add(h2, 17.0);
+ grpc_histogram_add(h2, 1.0);
+ GPR_ASSERT(grpc_histogram_merge(h1, h2) == 1);
+ GPR_ASSERT(grpc_histogram_count(h1) == 7);
+ GPR_ASSERT(grpc_histogram_minimum(h1) == 1.0);
+ GPR_ASSERT(grpc_histogram_maximum(h1) == 17.0);
+ GPR_ASSERT(grpc_histogram_sum(h1) == 42.0);
+ GPR_ASSERT(grpc_histogram_sum_of_squares(h1) == 431.5);
+ GPR_ASSERT(grpc_histogram_mean(h1) == 6.0);
+
+ /* test monotonicity */
+ last = 0.0;
+ for (i = 0; i < 100.0; i += 0.01) {
+ cur = grpc_histogram_percentile(h1, i);
+ GPR_ASSERT(cur >= last);
+ last = cur;
+ }
+
+ grpc_histogram_destroy(h1);
+ grpc_histogram_destroy(h2);
+}
+
+int main(void) {
+ test_no_op();
+ test_simple();
+ test_percentile();
+ test_merge();
+ return 0;
+}
diff --git a/test/cpp/qps/BUILD b/test/cpp/qps/BUILD
index 0d91d52f22..f1abb19e64 100644
--- a/test/cpp/qps/BUILD
+++ b/test/cpp/qps/BUILD
@@ -106,7 +106,7 @@ grpc_cc_library(
"histogram.h",
"stats.h",
],
- deps = ["//:gpr"],
+ deps = ["//test/core/util:grpc_test_util"],
)
grpc_cc_test(
diff --git a/test/cpp/qps/histogram.h b/test/cpp/qps/histogram.h
index e31d5d78a8..ba72b5b332 100644
--- a/test/cpp/qps/histogram.h
+++ b/test/cpp/qps/histogram.h
@@ -19,8 +19,8 @@
#ifndef TEST_QPS_HISTOGRAM_H
#define TEST_QPS_HISTOGRAM_H
-#include <grpc/support/histogram.h>
#include "src/proto/grpc/testing/stats.pb.h"
+#include "test/core/util/histogram.h"
namespace grpc {
namespace testing {
@@ -29,36 +29,36 @@ class Histogram {
public:
// TODO: look into making histogram params not hardcoded for C++
Histogram()
- : impl_(gpr_histogram_create(default_resolution(),
- default_max_possible())) {}
+ : impl_(grpc_histogram_create(default_resolution(),
+ default_max_possible())) {}
~Histogram() {
- if (impl_) gpr_histogram_destroy(impl_);
+ if (impl_) grpc_histogram_destroy(impl_);
}
Histogram(Histogram&& other) : impl_(other.impl_) { other.impl_ = nullptr; }
- void Merge(const Histogram& h) { gpr_histogram_merge(impl_, h.impl_); }
- void Add(double value) { gpr_histogram_add(impl_, value); }
+ void Merge(const Histogram& h) { grpc_histogram_merge(impl_, h.impl_); }
+ void Add(double value) { grpc_histogram_add(impl_, value); }
double Percentile(double pctile) const {
- return gpr_histogram_percentile(impl_, pctile);
+ return grpc_histogram_percentile(impl_, pctile);
}
- double Count() const { return gpr_histogram_count(impl_); }
+ double Count() const { return grpc_histogram_count(impl_); }
void Swap(Histogram* other) { std::swap(impl_, other->impl_); }
void FillProto(HistogramData* p) {
size_t n;
- const auto* data = gpr_histogram_get_contents(impl_, &n);
+ const auto* data = grpc_histogram_get_contents(impl_, &n);
for (size_t i = 0; i < n; i++) {
p->add_bucket(data[i]);
}
- p->set_min_seen(gpr_histogram_minimum(impl_));
- p->set_max_seen(gpr_histogram_maximum(impl_));
- p->set_sum(gpr_histogram_sum(impl_));
- p->set_sum_of_squares(gpr_histogram_sum_of_squares(impl_));
- p->set_count(gpr_histogram_count(impl_));
+ p->set_min_seen(grpc_histogram_minimum(impl_));
+ p->set_max_seen(grpc_histogram_maximum(impl_));
+ p->set_sum(grpc_histogram_sum(impl_));
+ p->set_sum_of_squares(grpc_histogram_sum_of_squares(impl_));
+ p->set_count(grpc_histogram_count(impl_));
}
void MergeProto(const HistogramData& p) {
- gpr_histogram_merge_contents(impl_, &*p.bucket().begin(), p.bucket_size(),
- p.min_seen(), p.max_seen(), p.sum(),
- p.sum_of_squares(), p.count());
+ grpc_histogram_merge_contents(impl_, &*p.bucket().begin(), p.bucket_size(),
+ p.min_seen(), p.max_seen(), p.sum(),
+ p.sum_of_squares(), p.count());
}
static double default_resolution() { return 0.01; }
@@ -68,7 +68,7 @@ class Histogram {
Histogram(const Histogram&);
Histogram& operator=(const Histogram&);
- gpr_histogram* impl_;
+ grpc_histogram* impl_;
};
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/qps/qps_interarrival_test.cc b/test/cpp/qps/qps_interarrival_test.cc
index 461bf624ce..625b7db426 100644
--- a/test/cpp/qps/qps_interarrival_test.cc
+++ b/test/cpp/qps/qps_interarrival_test.cc
@@ -20,7 +20,7 @@
#include <iostream>
// Use the C histogram rather than C++ to avoid depending on proto
-#include <grpc/support/histogram.h>
+#include "test/core/util/histogram.h"
#include "test/cpp/qps/interarrival.h"
#include "test/cpp/util/test_config.h"
@@ -31,21 +31,21 @@ using grpc::testing::RandomDistInterface;
static void RunTest(RandomDistInterface&& r, int threads, std::string title) {
InterarrivalTimer timer;
timer.init(r, threads);
- gpr_histogram* h(gpr_histogram_create(0.01, 60e9));
+ grpc_histogram* h(grpc_histogram_create(0.01, 60e9));
for (int i = 0; i < 10000000; i++) {
for (int j = 0; j < threads; j++) {
- gpr_histogram_add(h, timer.next(j));
+ grpc_histogram_add(h, timer.next(j));
}
}
std::cout << title << " Distribution" << std::endl;
std::cout << "Value, Percentile" << std::endl;
for (double pct = 0.0; pct < 100.0; pct += 1.0) {
- std::cout << gpr_histogram_percentile(h, pct) << "," << pct << std::endl;
+ std::cout << grpc_histogram_percentile(h, pct) << "," << pct << std::endl;
}
- gpr_histogram_destroy(h);
+ grpc_histogram_destroy(h);
}
using grpc::testing::ExpDist;
diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc
index c288b03ec5..4c9ab0ea43 100644
--- a/test/cpp/qps/qps_worker.cc
+++ b/test/cpp/qps/qps_worker.cc
@@ -32,12 +32,12 @@
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/cpu.h>
-#include <grpc/support/histogram.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include "src/proto/grpc/testing/services.pb.h"
#include "test/core/util/grpc_profiler.h"
+#include "test/core/util/histogram.h"
#include "test/cpp/qps/client.h"
#include "test/cpp/qps/server.h"
#include "test/cpp/util/create_test_channel.h"
diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++
index bd641c2542..e62278cb9f 100644
--- a/tools/doxygen/Doxyfile.c++
+++ b/tools/doxygen/Doxyfile.c++
@@ -913,7 +913,6 @@ include/grpc/support/atm_windows.h \
include/grpc/support/avl.h \
include/grpc/support/cmdline.h \
include/grpc/support/cpu.h \
-include/grpc/support/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal
index 09f668d847..d09b325c97 100644
--- a/tools/doxygen/Doxyfile.c++.internal
+++ b/tools/doxygen/Doxyfile.c++.internal
@@ -914,7 +914,6 @@ include/grpc/support/atm_windows.h \
include/grpc/support/avl.h \
include/grpc/support/cmdline.h \
include/grpc/support/cpu.h \
-include/grpc/support/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core
index 97bb43a423..6ce9041747 100644
--- a/tools/doxygen/Doxyfile.core
+++ b/tools/doxygen/Doxyfile.core
@@ -853,7 +853,6 @@ include/grpc/support/atm_windows.h \
include/grpc/support/avl.h \
include/grpc/support/cmdline.h \
include/grpc/support/cpu.h \
-include/grpc/support/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal
index 28b7d396e0..1aff0075a6 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -853,7 +853,6 @@ include/grpc/support/atm_windows.h \
include/grpc/support/avl.h \
include/grpc/support/cmdline.h \
include/grpc/support/cpu.h \
-include/grpc/support/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_windows.h \
@@ -1294,7 +1293,6 @@ src/core/lib/support/env_posix.cc \
src/core/lib/support/env_windows.cc \
src/core/lib/support/fork.cc \
src/core/lib/support/fork.h \
-src/core/lib/support/histogram.cc \
src/core/lib/support/host_port.cc \
src/core/lib/support/log.cc \
src/core/lib/support/log_android.cc \
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index c868acf8d3..a0ea4238e1 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -711,21 +711,6 @@
"headers": [],
"is_filegroup": false,
"language": "c",
- "name": "gpr_histogram_test",
- "src": [
- "test/core/support/histogram_test.cc"
- ],
- "third_party": false,
- "type": "target"
- },
- {
- "deps": [
- "gpr",
- "gpr_test_util"
- ],
- "headers": [],
- "is_filegroup": false,
- "language": "c",
"name": "gpr_host_port_test",
"src": [
"test/core/support/host_port_test.cc"
@@ -1245,6 +1230,21 @@
{
"deps": [
"gpr",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c",
+ "name": "histogram_test",
+ "src": [
+ "test/core/util/histogram_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
"gpr_test_util",
"grpc",
"grpc_test_util"
@@ -7766,7 +7766,6 @@
"src/core/lib/support/env_posix.cc",
"src/core/lib/support/env_windows.cc",
"src/core/lib/support/fork.cc",
- "src/core/lib/support/histogram.cc",
"src/core/lib/support/host_port.cc",
"src/core/lib/support/log.cc",
"src/core/lib/support/log_android.cc",
@@ -7813,7 +7812,6 @@
"include/grpc/support/avl.h",
"include/grpc/support/cmdline.h",
"include/grpc/support/cpu.h",
- "include/grpc/support/histogram.h",
"include/grpc/support/host_port.h",
"include/grpc/support/log.h",
"include/grpc/support/log_windows.h",
@@ -7863,7 +7861,6 @@
"include/grpc/support/avl.h",
"include/grpc/support/cmdline.h",
"include/grpc/support/cpu.h",
- "include/grpc/support/histogram.h",
"include/grpc/support/host_port.h",
"include/grpc/support/log.h",
"include/grpc/support/log_windows.h",
@@ -8928,6 +8925,7 @@
"test/core/iomgr/endpoint_tests.h",
"test/core/util/debugger_macros.h",
"test/core/util/grpc_profiler.h",
+ "test/core/util/histogram.h",
"test/core/util/memory_counters.h",
"test/core/util/mock_endpoint.h",
"test/core/util/parse_hexstring.h",
@@ -8956,6 +8954,8 @@
"test/core/util/debugger_macros.h",
"test/core/util/grpc_profiler.cc",
"test/core/util/grpc_profiler.h",
+ "test/core/util/histogram.cc",
+ "test/core/util/histogram.h",
"test/core/util/memory_counters.cc",
"test/core/util/memory_counters.h",
"test/core/util/mock_endpoint.cc",
diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json
index 929ed15918..ce698cb709 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -854,30 +854,6 @@
"flaky": false,
"gtest": false,
"language": "c",
- "name": "gpr_histogram_test",
- "platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ],
- "uses_polling": false
- },
- {
- "args": [],
- "benchmark": false,
- "ci_platforms": [
- "linux",
- "mac",
- "posix",
- "windows"
- ],
- "cpu_cost": 1.0,
- "exclude_configs": [],
- "exclude_iomgrs": [],
- "flaky": false,
- "gtest": false,
- "language": "c",
"name": "gpr_host_port_test",
"platforms": [
"linux",
@@ -1538,6 +1514,30 @@
"flaky": false,
"gtest": false,
"language": "c",
+ "name": "histogram_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "uses_polling": false
+ },
+ {
+ "args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
+ "posix",
+ "windows"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": false,
+ "language": "c",
"name": "hpack_parser_test",
"platforms": [
"linux",