Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit eaebfa0

Browse files
committed
add benchmark helper function and first benchmark
1 parent 1481e66 commit eaebfa0

2 files changed

Lines changed: 54 additions & 41 deletions

File tree

cmake/OpenCensusHelpers.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ function(opencensus_test NAME SRC)
3838
endif()
3939
endfunction()
4040

41+
# Helper function like bazel's cc_test. Usage:
42+
#
43+
# opencensus_benchmark(trace_some_test internal/some_test.cc dep1 dep2...)
44+
function(opencensus_benchmark NAME SRC)
45+
#if(BUILD_TESTING)
46+
set(_NAME "opencensus_${NAME}")
47+
add_executable(${_NAME} ${SRC})
48+
prepend_opencensus(DEPS "${ARGN}")
49+
target_link_libraries(${_NAME} "${DEPS}" benchmark)
50+
#add_test(NAME ${_NAME} COMMAND ${_NAME})
51+
#endif()
52+
endfunction()
53+
4154
# Helper function like bazel's cc_library. Libraries are namespaced as
4255
# opencensus_* and public libraries are also aliased as opencensus-cpp::*.
4356
function(opencensus_lib NAME)
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
# Copyright 2018, OpenCensus Authors
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
15-
opencensus_lib(common_hash_mix)
16-
17-
opencensus_lib(common_random
18-
SRCS
19-
random.cc
20-
DEPS
21-
absl::base
22-
absl::synchronization
23-
absl::time)
24-
25-
opencensus_lib(common_stats_object DEPS absl::time)
26-
27-
# Define NOMINMAX to fix build errors when compiling with MSVC.
28-
target_compile_definitions(opencensus_common_stats_object INTERFACE
29-
$<$<CXX_COMPILER_ID:MSVC>:NOMINMAX>)
30-
31-
opencensus_lib(common_string_vector_hash)
32-
33-
opencensus_test(common_random_test random_test.cc common_random)
34-
35-
opencensus_test(common_stats_object_test
36-
stats_object_test.cc
37-
common_stats_object
38-
absl::strings
39-
absl::span)
40-
41-
# TODO: random_benchmark
1+
# Copyright 2018, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
opencensus_lib(common_hash_mix)
16+
17+
opencensus_lib(common_random
18+
SRCS
19+
random.cc
20+
DEPS
21+
absl::base
22+
absl::synchronization
23+
absl::time)
24+
25+
opencensus_lib(common_stats_object DEPS absl::time)
26+
27+
# Define NOMINMAX to fix build errors when compiling with MSVC.
28+
target_compile_definitions(opencensus_common_stats_object INTERFACE
29+
$<$<CXX_COMPILER_ID:MSVC>:NOMINMAX>)
30+
31+
opencensus_lib(common_string_vector_hash)
32+
33+
opencensus_test(common_random_test random_test.cc common_random)
34+
35+
opencensus_benchmark(common_random_benchmark random_benchmark.cc common_random)
36+
37+
opencensus_test(common_stats_object_test
38+
stats_object_test.cc
39+
common_stats_object
40+
absl::strings
41+
absl::span)

0 commit comments

Comments
 (0)