Skip to content

Commit b6f5b9f

Browse files
committed
test: Add some benchmarks for various high level things.
1 parent 8a8d027 commit b6f5b9f

15 files changed

+943
-20
lines changed

CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ endif()
7777

7878
enable_testing()
7979
find_package(GTest)
80+
find_package(benchmark QUIET)
8081

8182
set(CMAKE_MACOSX_RPATH ON)
8283

@@ -671,3 +672,44 @@ endif()
671672
if (BUILD_FUZZ_TESTS)
672673
add_subdirectory(testing/fuzzing)
673674
endif()
675+
676+
################################################################################
677+
#
678+
# :: Benchmarks
679+
#
680+
################################################################################
681+
682+
if(UNITTEST AND benchmark_FOUND)
683+
if(BUILD_TOXAV AND TARGET av_test_support)
684+
add_executable(rtp_bench toxav/rtp_bench.cc)
685+
target_link_libraries(rtp_bench PRIVATE
686+
toxcore_static
687+
av_test_support
688+
benchmark::benchmark
689+
)
690+
691+
add_executable(audio_bench toxav/audio_bench.cc)
692+
target_link_libraries(audio_bench PRIVATE
693+
toxcore_static
694+
av_test_support
695+
benchmark::benchmark
696+
)
697+
698+
add_executable(video_bench toxav/video_bench.cc)
699+
target_link_libraries(video_bench PRIVATE
700+
toxcore_static
701+
av_test_support
702+
benchmark::benchmark
703+
)
704+
endif()
705+
706+
add_executable(sort_bench
707+
toxcore/sort_bench.cc
708+
toxcore/sort_test_util.cc
709+
toxcore/sort_test_util.hh
710+
)
711+
target_link_libraries(sort_bench PRIVATE
712+
toxcore_static
713+
benchmark::benchmark
714+
)
715+
endif()

testing/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ if(BUILD_MISC_TESTS)
3939
endif()
4040
endif()
4141

42+
add_subdirectory(bench)
4243
add_subdirectory(support)

testing/bench/BUILD.bazel

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_binary")
2+
3+
cc_binary(
4+
name = "tox_messenger_bench",
5+
testonly = True,
6+
srcs = ["tox_messenger_bench.cc"],
7+
deps = [
8+
"//c-toxcore/testing/support",
9+
"//c-toxcore/toxcore:tox",
10+
"@benchmark",
11+
],
12+
)
13+
14+
cc_binary(
15+
name = "tox_friends_scaling_bench",
16+
testonly = True,
17+
srcs = ["tox_friends_scaling_bench.cc"],
18+
deps = [
19+
"//c-toxcore/testing/support",
20+
"//c-toxcore/toxcore:tox",
21+
"@benchmark",
22+
],
23+
)

testing/bench/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if(NOT UNITTEST)
2+
return()
3+
endif()
4+
5+
find_package(benchmark QUIET)
6+
7+
if(benchmark_FOUND)
8+
add_executable(tox_messenger_bench tox_messenger_bench.cc)
9+
target_link_libraries(tox_messenger_bench PRIVATE
10+
toxcore_static
11+
support
12+
benchmark::benchmark
13+
)
14+
15+
add_executable(tox_friends_scaling_bench tox_friends_scaling_bench.cc)
16+
target_link_libraries(tox_friends_scaling_bench PRIVATE
17+
toxcore_static
18+
support
19+
benchmark::benchmark
20+
)
21+
endif()

0 commit comments

Comments
 (0)