Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ test_script:

& $_.FullName $cmdArgList
}
Get-ChildItem -Recurse -Path $env:APPVEYOR_BUILD_FOLDER -Filter "*_benchmark.exe" | ForEach-Object {
Write-Output $_.FullName

& $_.FullName
}

on_finish:
- ps: |
Expand Down
20 changes: 19 additions & 1 deletion cmake/OpenCensusDeps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ fetchcontent_declare(abseil
GIT_REPOSITORY
https://github.com/abseil/abseil-cpp
GIT_TAG
master)
2c8421e1c6cef0da9e8a20b01c15256ec9ec116d)
fetchcontent_declare(prometheus
GIT_REPOSITORY
https://github.com/jupp0r/prometheus-cpp
GIT_TAG
master)
fetchcontent_declare(benchmark
GIT_REPOSITORY
https://github.com/google/benchmark
GIT_TAG
master)

fetchcontent_getproperties(googletest)
if(BUILD_TESTING)
Expand Down Expand Up @@ -72,3 +77,16 @@ if(NOT prometheus_POPULATED)
add_subdirectory(${prometheus_SOURCE_DIR} ${prometheus_BINARY_DIR}
EXCLUDE_FROM_ALL)
endif()

fetchcontent_getproperties(benchmark)
if(NOT benchmark_POPULATED)
set(BENCHMARK_ENABLE_TESTING OFF
CACHE BOOL "Enable testing of the benchmark library."
FORCE)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF
CACHE BOOL "Enable building the unit tests which depend on gtest"
FORCE)
fetchcontent_populate(benchmark)
add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR}
EXCLUDE_FROM_ALL)
endif()
13 changes: 13 additions & 0 deletions cmake/OpenCensusHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ function(opencensus_test NAME SRC)
endif()
endfunction()

# Helper function like bazel's cc_benchmark. Usage:
#
# opencensus_benchmark(trace_some_benchmark internal/some_benchmark.cc dep1
# dep2...)
function(opencensus_benchmark NAME SRC)
if(BUILD_TESTING)
set(_NAME "opencensus_${NAME}")
add_executable(${_NAME} ${SRC})
prepend_opencensus(DEPS "${ARGN}")
target_link_libraries(${_NAME} "${DEPS}" benchmark)
endif()
endfunction()

# Helper function like bazel's cc_library. Libraries are namespaced as
# opencensus_* and public libraries are also aliased as opencensus-cpp::*.
function(opencensus_lib NAME)
Expand Down
4 changes: 2 additions & 2 deletions opencensus/common/internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ opencensus_lib(common_string_vector_hash)

opencensus_test(common_random_test random_test.cc common_random)

opencensus_benchmark(common_random_benchmark random_benchmark.cc common_random)

opencensus_test(common_stats_object_test
stats_object_test.cc
common_stats_object
absl::strings
absl::span)

# TODO: random_benchmark
3 changes: 2 additions & 1 deletion opencensus/context/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ opencensus_test(context_context_test

opencensus_test(context_with_context_test internal/with_context_test.cc context)

# TODO: context_benchmark
opencensus_benchmark(context_context_benchmark internal/context_benchmark.cc
context)
8 changes: 7 additions & 1 deletion opencensus/stats/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,10 @@ opencensus_test(stats_view_data_impl_test
stats_core
absl::time)

# TODO: benchmarks
opencensus_benchmark(stats_stats_manager_benchmark
internal/stats_manager_benchmark.cc
stats_core
stats_recording
absl::memory
absl::strings
absl::time)
5 changes: 4 additions & 1 deletion opencensus/tags/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,7 @@ opencensus_test(tags_with_tag_map_test
tags_with_tag_map
context)

# TODO: benchmarks
opencensus_benchmark(tags_tag_map_benchmark
internal/tag_map_benchmark.cc
tags
absl::strings)
26 changes: 25 additions & 1 deletion opencensus/trace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,28 @@ opencensus_test(trace_with_span_test
trace_with_span
context)

# TODO: benchmarks
opencensus_benchmark(trace_attribute_value_ref_benchmark
internal/attribute_value_ref_benchmark.cc trace)

opencensus_benchmark(trace_cloud_trace_context_benchmark
internal/cloud_trace_context_benchmark.cc
trace_cloud_trace_context)

opencensus_benchmark(trace_grpc_trace_bin_benchmark
internal/grpc_trace_bin_benchmark.cc trace_grpc_trace_bin)

opencensus_benchmark(trace_span_benchmark
internal/span_benchmark.cc
trace_span_context
trace)

opencensus_benchmark(trace_span_id_benchmark internal/span_id_benchmark.cc
trace_span_context)

opencensus_benchmark(trace_context_benchmark internal/trace_context_benchmark.cc
trace_trace_context)

opencensus_benchmark(trace_with_span_benchmark
internal/with_span_benchmark.cc
trace
trace_with_span)