Skip to content

Commit 00d19f2

Browse files
committed
temp
1 parent 13367e4 commit 00d19f2

File tree

91 files changed

+5987
-1055
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+5987
-1055
lines changed

.clang-format

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ BraceWrapping:
2020
BeforeLambdaBody: true
2121
AlignEscapedNewlines: Right
2222
ContinuationIndentWidth: 2
23+
ConstructorInitializerIndentWidth: 2
2324
AlignAfterOpenBracket: Align # TODO(MBkkt) Try BlockIndent clang-format 15
2425

2526
IncludeCategories:
@@ -32,3 +33,4 @@ IncludeCategories:
3233
- Regex: '.*' # other libraries (system headers in our case)
3334
Priority: 50
3435
IncludeBlocks: Regroup
36+
IndentPPDirectives: AfterHash

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @MBkkt
1+
* @MBkkt

.github/workflows/format.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
name: Format
22

33
on:
4+
workflow_dispatch:
45
push:
5-
branches: [ master, main ]
6-
paths-ignore: [ '**/result/**', '**.md' ]
6+
branches: [ main ]
7+
paths: [ '**.cpp', '**.hpp' ]
78
pull_request:
8-
branches: [ master, main ]
9-
paths-ignore: [ '**/result/**', '**.md' ]
9+
branches: [ main ]
10+
paths: [ '**.cpp', '**.hpp' ]
1011

1112
jobs:
1213
# TODO(MBkkt) clang-format 14, now this extension doesn't work, because clang-14 not really released yet
@@ -16,17 +17,17 @@ jobs:
1617
# TODO(MBkkt) Add option or workflow for reformat
1718

1819
main:
19-
runs-on: ubuntu-20.04
20+
runs-on: ubuntu-22.04
2021
strategy:
2122
fail-fast: false
2223
matrix:
2324
path:
2425
- '.'
2526

2627
steps:
27-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v3
2829
- name: Run clang-format style check
29-
uses: jidicula/clang-format-action@v4.5.0
30+
uses: jidicula/clang-format-action@v4.6.2
3031
with:
3132
clang-format-version: 13
3233
check-path: ${{ matrix.path }}

.github/workflows/linux.yml

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,69 @@
1-
name: Sanitizer
1+
name: Linux
22

33
on:
4+
workflow_dispatch:
45
push:
5-
branches: [ master, main ]
6-
paths-ignore: [ '**/result/**', '**.md' ]
6+
branches: [ main ]
7+
paths: [ '**.cpp', '**.hpp', '**.cmake', '**/CMakeLists.txt' ]
78
pull_request:
8-
branches: [ master, main ]
9-
paths-ignore: [ '**/result/**', '**.md' ]
9+
branches: [ main ]
10+
paths: [ '**.cpp', '**.hpp', '**.cmake' ]
1011

1112
jobs:
1213
main:
1314
runs-on: ${{ matrix.os }}
1415
strategy:
1516
fail-fast: false
1617
matrix:
17-
os: [ ubuntu-20.04 ]
18+
os: [ ubuntu-22.04 ]
1819
build_type: [ Debug, RelWithDebInfo ]
1920
compiler: [ clang_libcxx, clang_libstdcxx, gcc_libstdcxx ]
2021

2122
steps:
22-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v3
2324

2425
- name: Update deps on Linux
2526
run: |
2627
sudo apt-get update
2728
sudo wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
28-
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"
29+
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main"
2930
sudo apt-get update
3031
sudo apt-get install ninja-build gcc-11 g++-11 libstdc++-11-dev clang-14 lld-14 libc++-14-dev libc++abi-14-dev libboost-thread-dev
3132
sudo ln -sf /usr/bin/lld-14 /usr/local/bin/ld
33+
sudo update-alternatives \
34+
--install /usr/bin/gcc gcc /usr/bin/gcc-11 200 \
35+
--slave /usr/bin/g++ g++ /usr/bin/g++-11 \
36+
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 \
37+
--slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-11 \
38+
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11 \
39+
--slave /usr/bin/gcov gcov /usr/bin/gcov-11 \
40+
--slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-11 \
41+
--slave /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-11
42+
sudo update-alternatives --auto gcc
43+
sudo update-alternatives \
44+
--install /usr/bin/cpp cpp /usr/bin/cpp-11 200
45+
sudo update-alternatives --auto cpp
3246
3347
- name: Configure CMake Posix
3448
run: |
3549
build_type=${{ matrix.build_type }}
3650
dir="build_${{ matrix.compiler }}"
3751
if [[ "${{ matrix.compiler }}" == "gcc_libstdcxx" ]]; then
38-
c_compiler=gcc-11; cxx_compiler=g++-11
52+
cxx_compiler=g++-11
3953
else
40-
c_compiler=clang-14; cxx_compiler=clang++-14
54+
cxx_compiler=clang++-14
4155
fi
4256
if [[ "${{ matrix.compiler }}" == "clang_libcxx" ]]; then
43-
options="-DLIBCXX=ON -DSTD=ON -DYACLIB=main"
57+
options="-DLIBCXX=ON"
4458
else
45-
options=" -DSTD=ON -DYACLIB=main -DBOOST_THREAD=ON"
59+
options="-DBOOST_THREAD=ON"
4660
fi
47-
cmake -S . -B $dir \
48-
-DCMAKE_BUILD_TYPE=$build_type \
49-
-DCMAKE_C_COMPILER=${c_compiler} \
50-
-DCMAKE_CXX_COMPILER=${cxx_compiler} \
51-
-G"Ninja" \
61+
cmake -S . -B $dir \
62+
-DCMAKE_BUILD_TYPE=$build_type \
63+
-DCMAKE_CXX_COMPILER=${cxx_compiler} \
64+
-G"Ninja" \
65+
-DSTD=ON \
66+
-DYACLIB=v2022.08.23 \
5267
$options
5368
5469
- name: Build

CMakeLists.txt

Lines changed: 110 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,21 @@ if (BENCH_SOURCE_DIR STREQUAL BENCH_BINARY_DIR)
1111
endif ()
1212

1313
# Set variables
14-
set(CMAKE_CXX_STANDARD 17)
14+
set(CMAKE_CXX_STANDARD 20)
1515
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1616
set(CMAKE_CXX_EXTENSIONS OFF)
1717
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
1818

19-
set(CMAKE_C_STANDARD 11)
20-
set(CMAKE_C_STANDARD_REQUIRED ON)
21-
set(CMAKE_C_EXTENSIONS OFF)
22-
set(CMAKE_C_VISIBILITY_PRESET hidden)
23-
2419
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
25-
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2620
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
2721

2822
message("COMPILE_OPTIONS: ${COMPILE_OPTIONS}")
2923
message("LINK_OPTIONS : ${LINK_OPTIONS}")
24+
25+
include(FetchContent)
26+
3027
if (LIBCXX)
31-
add_compile_options(-stdlib=libc++)
28+
add_compile_options(-stdlib=libc++ -fno-inline)
3229
add_link_options(-stdlib=libc++ -lc++abi)
3330
endif ()
3431

@@ -40,7 +37,6 @@ set(UTIL_HEADERS
4037
find_package(benchmark QUIET)
4138

4239
if (NOT BENCHMARK_FOUND)
43-
include(FetchContent)
4440
if (NOT BENCHMARK_FOUND)
4541
set(BENCHMARK_ENABLE_TESTING NO)
4642
FetchContent_Declare(
@@ -52,4 +48,108 @@ if (NOT BENCHMARK_FOUND)
5248
endif ()
5349
endif ()
5450

55-
add_subdirectory(future)
51+
function(add_bench BENCH_NAME)
52+
add_executable(${BENCH_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/test/${BENCH_NAME}/${BENCH_NAME}.cpp)
53+
target_link_libraries(${BENCH_NAME}
54+
PRIVATE ${GTEST_BOTH_LIBRARIES}
55+
PRIVATE benchmark::benchmark
56+
PRIVATE ${PROJECT_NAME}
57+
)
58+
59+
if (STD)
60+
target_compile_definitions(${BENCH_NAME} PUBLIC STD_ENABLE)
61+
endif ()
62+
if (YACLIB)
63+
target_compile_definitions(${BENCH_NAME} PUBLIC YACLIB_ENABLE)
64+
endif ()
65+
if (CPPCORO)
66+
target_compile_definitions(${BENCH_NAME} PUBLIC CPPCORO_ENABLE)
67+
endif ()
68+
if (FOLLY)
69+
target_compile_definitions(${BENCH_NAME} PUBLIC FOLLY_ENABLE)
70+
endif ()
71+
if (ARANGODB)
72+
target_compile_definitions(${BENCH_NAME} PUBLIC ARANGODB_ENABLE)
73+
endif ()
74+
if (BOOST_THREAD)
75+
target_compile_definitions(${BENCH_NAME} PUBLIC BOOST_THREAD_ENABLE)
76+
endif ()
77+
if (QT)
78+
target_compile_definitions(${BENCH_NAME} PUBLIC QT_ENABLE)
79+
endif ()
80+
if (EXPERIMENTAL)
81+
target_compile_definitions(${BENCH_NAME} PUBLIC EXPERIMENTAL_ENABLE)
82+
endif ()
83+
84+
add_test(NAME ${BENCH_NAME} COMMAND ${BENCH_NAME})
85+
endfunction()
86+
87+
find_package(Threads REQUIRED)
88+
link_libraries(Threads::Threads)
89+
include_directories(vendor)
90+
91+
if (YACLIB) # v2022.08.31
92+
FetchContent_Declare(yaclib
93+
GIT_REPOSITORY https://github.com/YACLib/YACLib.git
94+
GIT_TAG "${YACLIB}"
95+
)
96+
list(APPEND YACLIB_FLAGS "CORO")
97+
FetchContent_MakeAvailable(yaclib)
98+
link_libraries(yaclib)
99+
endif ()
100+
if (FOLLY)
101+
find_package(glog CONFIG REQUIRED) # Ad-hoc
102+
find_package(folly CONFIG REQUIRED)
103+
include_directories(${FOLLY_INCLUDE_DIR})
104+
link_libraries(Folly::folly)
105+
endif ()
106+
if (ARANGODB)
107+
add_library(arangodb STATIC
108+
${CMAKE_CURRENT_SOURCE_DIR}/vendor/arangodb/futures/Future.cpp
109+
)
110+
endif ()
111+
if (BOOST_THREAD)
112+
find_package(Boost COMPONENTS thread REQUIRED)
113+
link_libraries(Boost::thread)
114+
endif ()
115+
if (QT)
116+
find_package(Qt6 COMPONENTS Concurrent REQUIRED)
117+
link_libraries(Qt6::Concurrent)
118+
endif ()
119+
if (EXPERIMENTAL)
120+
add_link_options(-lc++experimental)
121+
endif ()
122+
if (CPPCORO)
123+
FetchContent_Declare(cppcoro
124+
GIT_REPOSITORY https://github.com/YACLib/cppcoro-for-benchmark.git
125+
GIT_TAG main
126+
)
127+
FetchContent_MakeAvailable(cppcoro)
128+
link_libraries(cppcoro)
129+
endif ()
130+
131+
macro(add_files)
132+
set(BENCH_HEADERS ${BENCH_HEADERS} PARENT_SCOPE)
133+
set(BENCH_SOURCES ${BENCH_SOURCES} PARENT_SCOPE)
134+
endmacro()
135+
136+
add_subdirectory(bind)
137+
add_subdirectory(bench)
138+
add_library(${PROJECT_NAME} STATIC)
139+
140+
target_sources(${PROJECT_NAME}
141+
PRIVATE ${BENCH_SOURCES}
142+
PRIVATE ${BENCH_HEADERS}
143+
)
144+
145+
target_include_directories(${PROJECT_NAME}
146+
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
147+
)
148+
149+
target_link_libraries(${PROJECT_NAME}
150+
PRIVATE ${GTEST_BOTH_LIBRARIES}
151+
PUBLIC benchmark::benchmark
152+
)
153+
154+
add_bench(future)
155+
add_bench(coro)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Results
44

5-
Future benchmark [results](future/result/RESULTS.md).
5+
Future benchmark [results](test/future/result/RESULTS.md).
66

77
## How to add your own results
88

bench/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_files()

bench/async_mutex.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
#include <thread>
4+
5+
#include <benchmark/benchmark.h>
6+
7+
namespace bench {
8+
9+
template <typename Library>
10+
void AsyncMutex(benchmark::State& state) {
11+
auto* executor = Library::AcquireExecutor(std::thread::hardware_concurrency());
12+
for (auto _ : state) {
13+
Library::AsyncMutex(executor);
14+
executor->Restart();
15+
}
16+
Library::ReleaseExecutor(executor);
17+
}
18+
19+
} // namespace bench

bench/collatz.hpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#pragma once
2+
3+
#include <benchmark/benchmark.h>
4+
5+
namespace bench {
6+
7+
template <typename Library>
8+
void CollatzEager(benchmark::State& state) {
9+
const auto x = state.range(0);
10+
for (auto _ : state) {
11+
Library::CollatzEager(x);
12+
}
13+
}
14+
15+
template <typename Library>
16+
void CollatzLazy(benchmark::State& state) {
17+
const auto x = state.range(0);
18+
for (auto _ : state) {
19+
Library::CollatzLazy(x);
20+
}
21+
}
22+
23+
} // namespace bench

future/bench/complex.hpp renamed to bench/complex.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
#pragma once
2+
3+
#include <util/blob.hpp>
4+
15
#include <cstddef>
26

37
#include <benchmark/benchmark.h>
48

59
namespace bench {
610

7-
template <std::size_t Size>
8-
struct Blob {
9-
std::byte buffer[Size];
10-
};
11-
12-
template <typename Library, size_t N>
11+
template <typename Library, std::size_t N>
1312
void ComplexBlob(benchmark::State& state) {
1413
for (auto _ : state) {
1514
if constexpr (N == 0) {

0 commit comments

Comments
 (0)