Skip to content

Commit

Permalink
Update compiler version in github action
Browse files Browse the repository at this point in the history
Optimize benchmark cost
  • Loading branch information
owent committed Dec 1, 2020
1 parent 76321a3 commit 2963a61
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 94 deletions.
154 changes: 77 additions & 77 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
# setup @see https://help.github.com/en/articles/workflow-syntax-for-github-actions
# environment @see https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions
# https://help.github.com/en/articles/virtual-environments-for-github-actions
# example @see https://github.com/actions/toolkit/blob/master/.github/workflows/workflow.yml
name: Linux Building
# This workflow is triggered on pushes to the repository.
on: # @see https://help.github.com/en/articles/events-that-trigger-workflows#webhook-events
push:
branches: # Array of patterns that match refs/heads
# - master # Push events on master branch
- dev
# schedule:
# - cron: 0 * * * *

jobs:
build: # job id, can be any string
# Job name is Build And Publish
name: Build And Publish
# This job runs on Linux
strategy:
matrix:
os: [ubuntu-latest]
cc:
# - clang-6.0
# - clang-9
- gcc
- gcc-9
- shared:gcc-9
- no-exceptions:gcc-9
- thread-unsafe:gcc-9
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@master # https://github.com/actions/actions
- name: Build
shell: bash
run: |
PROJECT_ADDON_OPTIONS=()
USE_CC=${{ matrix.cc }}
if [[ "x${USE_CC:0:14}" == "xno-exceptions:" ]]; then
USE_CC=${USE_CC:14}
PROJECT_ADDON_OPTIONS=(${PROJECT_ADDON_OPTIONS[@]} "-DCMAKE_CXX_FLAGS=-fno-exceptions")
fi
if [[ "x${USE_CC:0:7}" == "xshared:" ]]; then
USE_CC=${USE_CC:7}
PROJECT_ADDON_OPTIONS=(${PROJECT_ADDON_OPTIONS[@]} "-DBUILD_SHARED_LIBS=ON")
fi
if [[ "x${USE_CC:0:14}" == "xthread-unsafe:" ]]; then
USE_CC=${USE_CC:14}
PROJECT_ADDON_OPTIONS=(${PROJECT_ADDON_OPTIONS[@]} "-DLIBCOPP_DISABLE_ATOMIC_LOCK=ON" "-DLIBCOPP_DISABLE_THIS_MT=ON")
fi
USE_CXX="$(echo $USE_CC | rev | sed -e 's/gnalc/++gnalc/' | rev)" # clang -> clang++
USE_CXX="$(echo $USE_CXX | rev | sed -e 's/ccg/++g/' | rev)" # gcc -> g++
mkdir -p "$GITHUB_WORKSPACE/build_jobs_dir_linux"
cd "$GITHUB_WORKSPACE/build_jobs_dir_linux"
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLIBCOPP_FCONTEXT_USE_TSX=ON -DPROJECT_ENABLE_UNITTEST=ON -DPROJECT_ENABLE_SAMPLE=ON -DCMAKE_C_COMPILER=$USE_CC -DCMAKE_CXX_COMPILER=$USE_CXX ${PROJECT_ADDON_OPTIONS[@]}
cmake --build . -j
- name: Sample and Tests
shell: bash
run: |
cd "$GITHUB_WORKSPACE/build_jobs_dir_linux"
ORIGIN_CC=${{ matrix.cc }}
if [ "x${ORIGIN_CC:0:14}" == "xno-exceptions:" ]; then
ORIGIN_CC=${ORIGIN_CC:14}
fi
if [ "x${ORIGIN_CC:0:7}" == "xshared:" ]; then
ORIGIN_CC=${ORIGIN_CC:7}
fi
if [ "x${ORIGIN_CC:0:14}" == "xthread-unsafe:" ]; then
ORIGIN_CC=${ORIGIN_CC:14}
echo "============================== run benchmark =============================="
cmake --build . -- benchmark
else
echo "============================== run sample,test,benchmark =============================="
cmake --build . -- run_sample run_test benchmark
fi
rm -rf *
# setup @see https://help.github.com/en/articles/workflow-syntax-for-github-actions
# environment @see https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions
# https://help.github.com/en/articles/virtual-environments-for-github-actions
# example @see https://github.com/actions/toolkit/blob/master/.github/workflows/workflow.yml
name: Linux Building
# This workflow is triggered on pushes to the repository.
on: # @see https://help.github.com/en/articles/events-that-trigger-workflows#webhook-events
push:
branches: # Array of patterns that match refs/heads
# - master # Push events on master branch
- dev
# schedule:
# - cron: 0 * * * *

jobs:
build: # job id, can be any string
# Job name is Build And Publish
name: Build And Publish
# This job runs on Linux
strategy:
matrix:
os: [ubuntu-latest]
cc:
# - clang-6.0
# - clang-9
- gcc
- gcc-10
- shared:gcc-10
- no-exceptions:gcc-10
- thread-unsafe:gcc-10
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@master # https://github.com/actions/actions
- name: Build
shell: bash
run: |
PROJECT_ADDON_OPTIONS=()
USE_CC=${{ matrix.cc }}
if [[ "x${USE_CC:0:14}" == "xno-exceptions:" ]]; then
USE_CC=${USE_CC:14}
PROJECT_ADDON_OPTIONS=(${PROJECT_ADDON_OPTIONS[@]} "-DCMAKE_CXX_FLAGS=-fno-exceptions")
fi
if [[ "x${USE_CC:0:7}" == "xshared:" ]]; then
USE_CC=${USE_CC:7}
PROJECT_ADDON_OPTIONS=(${PROJECT_ADDON_OPTIONS[@]} "-DBUILD_SHARED_LIBS=ON")
fi
if [[ "x${USE_CC:0:14}" == "xthread-unsafe:" ]]; then
USE_CC=${USE_CC:14}
PROJECT_ADDON_OPTIONS=(${PROJECT_ADDON_OPTIONS[@]} "-DLIBCOPP_DISABLE_ATOMIC_LOCK=ON" "-DLIBCOPP_DISABLE_THIS_MT=ON")
fi
USE_CXX="$(echo $USE_CC | rev | sed -e 's/gnalc/++gnalc/' | rev)" # clang -> clang++
USE_CXX="$(echo $USE_CXX | rev | sed -e 's/ccg/++g/' | rev)" # gcc -> g++
mkdir -p "$GITHUB_WORKSPACE/build_jobs_dir_linux"
cd "$GITHUB_WORKSPACE/build_jobs_dir_linux"
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLIBCOPP_FCONTEXT_USE_TSX=ON -DPROJECT_ENABLE_UNITTEST=ON -DPROJECT_ENABLE_SAMPLE=ON -DCMAKE_C_COMPILER=$USE_CC -DCMAKE_CXX_COMPILER=$USE_CXX ${PROJECT_ADDON_OPTIONS[@]}
cmake --build . -j
- name: Sample and Tests
shell: bash
run: |
cd "$GITHUB_WORKSPACE/build_jobs_dir_linux"
ORIGIN_CC=${{ matrix.cc }}
if [ "x${ORIGIN_CC:0:14}" == "xno-exceptions:" ]; then
ORIGIN_CC=${ORIGIN_CC:14}
fi
if [ "x${ORIGIN_CC:0:7}" == "xshared:" ]; then
ORIGIN_CC=${ORIGIN_CC:7}
fi
if [ "x${ORIGIN_CC:0:14}" == "xthread-unsafe:" ]; then
ORIGIN_CC=${ORIGIN_CC:14}
echo "============================== run benchmark =============================="
cmake --build . -- benchmark
else
echo "============================== run sample,test,benchmark =============================="
cmake --build . -- run_sample run_test benchmark
fi
rm -rf *
7 changes: 4 additions & 3 deletions sample/sample_benchmark_coroutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ int switch_count = 100;
static int my_runner(void *) {
// ... your code here ...
int count = switch_count; // 每个协程N次切换

while (count-- > 0)
copp::this_coroutine::yield();
copp::coroutine_context* self = copp::this_coroutine::get_coroutine();
while (count-- > 0) {
self->yield();
}

return 1;
}
Expand Down
4 changes: 2 additions & 2 deletions sample/sample_benchmark_coroutine_malloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ typedef copp::coroutine_context_container<copp::allocator::stack_allocator_mallo
static int my_runner(void *) {
// ... your code here ...
int count = switch_count; // 每个协程N次切换

copp::coroutine_context* self = copp::this_coroutine::get_coroutine();
while (count-- > 0) {
copp::this_coroutine::yield();
self->yield();
}

return 1;
Expand Down
3 changes: 2 additions & 1 deletion sample/sample_benchmark_coroutine_mem_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ typedef copp::coroutine_context_container<copp::allocator::stack_allocator_memor
static int my_runner(void *) {
// ... your code here ...
int count = switch_count; // 每个协程N次切换
copp::coroutine_context* self = copp::this_coroutine::get_coroutine();
while (count-- > 0) {
copp::this_coroutine::yield();
self->yield();
}

return 1;
Expand Down
3 changes: 2 additions & 1 deletion sample/sample_benchmark_coroutine_stack_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ typedef copp::coroutine_context_container<copp::allocator::stack_allocator_pool<
static int my_runner(void *) {
// ... your code here ...
int count = switch_count; // 每个协程N次切换
copp::coroutine_context* self = copp::this_coroutine::get_coroutine();
while (count-- > 0) {
copp::this_coroutine::yield();
self->yield();
}

return 1;
Expand Down
7 changes: 4 additions & 3 deletions sample/sample_benchmark_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ std::vector<my_task_t::ptr_t> task_arr;
static int my_task_action(void *) {
// ... your code here ...
int count = switch_count; // 每个task地切换次数

while (count-- > 0)
cotask::this_task::get_task()->yield();
cotask::impl::task_impl* self = cotask::this_task::get_task();
while (count-- > 0) {
self->yield();
}

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions sample/sample_benchmark_task_malloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ std::vector<my_task_t::ptr_t> task_arr;
int my_task_action(void *) {
// ... your code here ...
int count = switch_count; // 每个task地切换次数

cotask::impl::task_impl* self = cotask::this_task::get_task();
while (count-- > 0) {
cotask::this_task::get_task()->yield();
self->yield();
}

return 0;
Expand Down
7 changes: 4 additions & 3 deletions sample/sample_benchmark_task_mem_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ std::vector<my_task_t::ptr_t> task_arr;
int my_task_action(void *) {
// ... your code here ...
int count = switch_count; // 每个task地切换次数

while (count-- > 0)
cotask::this_task::get_task()->yield();
cotask::impl::task_impl* self = cotask::this_task::get_task();
while (count-- > 0) {
self->yield();
}

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions sample/sample_benchmark_task_stack_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ std::vector<my_task_t::ptr_t> task_arr;
int my_task_action(void *) {
// ... your code here ...
int count = switch_count; // 每个task地切换次数

cotask::impl::task_impl* self = cotask::this_task::get_task();
while (count-- > 0) {
cotask::this_task::get_task()->yield();
self->yield();
}

return 0;
Expand Down

0 comments on commit 2963a61

Please sign in to comment.