Skip to content

Commit

Permalink
using CI to run benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Apr 1, 2017
1 parent 3fe1b54 commit e738c26
Show file tree
Hide file tree
Showing 23 changed files with 235 additions and 126 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env:
global:
- LANG="zh_CN.UTF-8"
- CMAKE_PREFIX=$HOME/prebuilt/cmake ;
- CMAKE_VERSION=3.5.2 ;
- CMAKE_VERSION=3.7.2 ;
matrix:
include:
- os: osx
Expand Down Expand Up @@ -86,11 +86,12 @@ script:
- REPO_DIR=$PWD;
- mkdir -p $REPO_DIR/build && cd $REPO_DIR/build ;
- echo "$CMAKE_PREFIX/bin/cmake .. -DPROJECT_ENABLE_UNITTEST=ON -DPROJECT_ENABLE_SAMPLE=ON -DCMAKE_C_COMPILER=$USE_CC -DCMAKE_CXX_COMPILER=$USE_CXX" ;
- $CMAKE_PREFIX/bin/cmake .. -DPROJECT_ENABLE_UNITTEST=ON -DPROJECT_ENABLE_SAMPLE=ON -DCMAKE_C_COMPILER=$USE_CC -DCMAKE_CXX_COMPILER=$USE_CXX ;
- $CMAKE_PREFIX/bin/cmake .. -DCMAKE_BUILD_TYPE=Release -DPROJECT_ENABLE_UNITTEST=ON -DPROJECT_ENABLE_SAMPLE=ON -DCMAKE_C_COMPILER=$USE_CC -DCMAKE_CXX_COMPILER=$USE_CXX ;
- make -j4

after_success:
- test/coroutine_test
- cd $REPO_DIR/build ;
- make make unit_test benchmark ;

cache:
apt: true
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ configure_file(
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/src")

if(PROJECT_ENABLE_SAMPLE)
add_custom_target(benchmark)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/sample")
endif()

if(PROJECT_ENABLE_UNITTEST)
add_custom_target(unit_test)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/test")
endif()
endif()
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2016 OWenT
Copyright (c) 2017 OWenT

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
39 changes: 24 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
libcopp
=======

> cross-platform coroutine library of c++
> cross-platform coroutine library in c++
>
> in developing ...
>
> Build & Run Unit Test in | Linux+OSX(Clang+GCC) | Windows(VC+MinGW) |
> -------------------------|-----------------------|-------------|
> Status | [![Build Status](https://travis-ci.org/owt5008137/libcopp.svg?branch=master)](https://travis-ci.org/owt5008137/libcopp) | [![Build status](https://ci.appveyor.com/api/projects/status/7w6dfnpeahfmgaqj?svg=true)](https://ci.appveyor.com/project/owt5008137/libcopp) |
> Compilers | linux-gcc-4.4 <br /> linux-gcc-4.6 <br /> linux-gcc-4.9 <br /> linux-gcc-6 <br /> linux-clang-3.5 <br /> osx-apple-clang-6.0 <br /> | MSVC 12(Visual Studio 2013) <br /> MSVC 14(Visual Studio 2015) <br /> Mingw64-gcc
> Compilers | linux-gcc-4.4 <br /> linux-gcc-4.6 <br /> linux-gcc-4.9 <br /> linux-gcc-6 <br /> linux-clang-3.5 <br /> osx-apple-clang-6.0 <br /> | MSVC 12(Visual Studio 2013) <br /> MSVC 14(Visual Studio 2015) <br /> MinGW64-gcc
>

Expand All @@ -28,6 +28,7 @@ Generate document with doxygen.

Doxygen file located at *doc/libcopp.doxyfile* .


INSTALL
=======

Expand Down Expand Up @@ -78,14 +79,19 @@ Build

**4. run test** *[optional]*

test/coroutine_test
make unit_test

**5. run benchmark** *[optional]*

**5. install** *[optional]*
make benchmark

**6. install** *[optional]*

make install

> Or you can just copy include directory and libcopp.a in lib or lib64 into your project to use it.

USAGE
=====

Expand Down Expand Up @@ -163,20 +169,20 @@ typedef cotask::task<> my_task_t;
int main(int argc, char* argv[]) {
// create a task using factory function [with lambda expression]
my_task_t::prt_t task = my_task_t::create([](){
std::cout<< "task "<< cotask::this_task::get_task()->get_id()<< " started"<< std::endl;
my_task_t::prt_t task = my_task_t::create([](){
std::cout<< "task "<< cotask::this_task::get_task()->get_id()<< " started"<< std::endl;
cotask::this_task::get_task()->yield();
std::cout<< "task "<< cotask::this_task::get_task()->get_id()<< " resumed"<< std::endl;
return 0;
std::cout<< "task "<< cotask::this_task::get_task()->get_id()<< " resumed"<< std::endl;
return 0;
});
std::cout<< "task "<< task->get_id()<< " created"<< std::endl;
std::cout<< "task "<< task->get_id()<< " created"<< std::endl;
// start a task
task->start();
std::cout<< "task "<< task->get_id()<< " yield"<< std::endl;
task->resume();
std::cout<< "task "<< task->get_id()<< " stoped, ready to be destroyed."<< std::endl;
std::cout<< "task "<< task->get_id()<< " yield"<< std::endl;
task->resume();
std::cout<< "task "<< task->get_id()<< " stoped, ready to be destroyed."<< std::endl;
return 0;
}
Expand Down Expand Up @@ -226,9 +232,12 @@ HISTORY
------
v0.1.0

CONSTRIBUTORS
======
+ [owent](https://github.com/owt5008137)

THANKS TO
========
======

[mutouyun](https://github.com/mutouyun)
+ [mutouyun](https://github.com/mutouyun)

16 changes: 9 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ environment:
- os: MinGW
CMAKE_GEN: MinGW64

configuration: RelWithDebInfo
configuration: Release

#
# Cache Cygwin files to speed up build
Expand Down Expand Up @@ -130,15 +130,15 @@ build_script:
if ( "$Env:CMAKE_GEN" -ieq "MinGW32" ) {
echo "$Env:MSYS2_PREFIX/msys2_shell -mingw32 -lc cd '$Env:APPVEYOR_BUILD_FOLDER/build'; mkdir build cmake .. -G 'MSYS Makefiles' -DPROJECT_ENABLE_UNITTEST=ON -DPROJECT_ENABLE_SAMPLE=ON ; make -j4"
echo "$Env:MSYS2_PREFIX/msys2_shell -mingw32 -lc cd '$Env:APPVEYOR_BUILD_FOLDER/build'; mkdir build cmake .. -G 'MSYS Makefiles' -DPROJECT_ENABLE_UNITTEST=ON -DPROJECT_ENABLE_SAMPLE=ON -DCMAKE_BUILD_TYPE=$Env:CONFIGURATION ; make -j4"
& "$Env:MSYS2_PREFIX/msys2_shell" -mingw32 -lc "cd '$Env:APPVEYOR_BUILD_FOLDER/build'; cmake .. -G 'MSYS Makefiles' -DPROJECT_ENABLE_UNITTEST=ON -DPROJECT_ENABLE_SAMPLE=ON > '$Env:MSYS2_LOG_FILE' 2>&1; make -j4 >> '$Env:MSYS2_LOG_FILE' 2>&1" | Out-Host
Get-Content "$Env:MSYS2_LOG_FILE"
} else {
echo "$Env:MSYS2_PREFIX/msys2_shell -mingw64 -lc cd '$Env:APPVEYOR_BUILD_FOLDER/build'; cmake .. -G 'MSYS Makefiles' -DPROJECT_ENABLE_UNITTEST=ON -DPROJECT_ENABLE_SAMPLE=ON ; make -j4"
echo "$Env:MSYS2_PREFIX/msys2_shell -mingw64 -lc cd '$Env:APPVEYOR_BUILD_FOLDER/build'; cmake .. -G 'MSYS Makefiles' -DPROJECT_ENABLE_UNITTEST=ON -DPROJECT_ENABLE_SAMPLE=ON -DCMAKE_BUILD_TYPE=$Env:CONFIGURATION ; make -j4"
& "$Env:MSYS2_PREFIX/msys2_shell" -mingw64 -lc "cd '$Env:APPVEYOR_BUILD_FOLDER/build'; cmake .. -G 'MSYS Makefiles' -DPROJECT_ENABLE_UNITTEST=ON -DPROJECT_ENABLE_SAMPLE=ON > '$Env:MSYS2_LOG_FILE' 2>&1; make -j4 >> '$Env:MSYS2_LOG_FILE' 2>&1" | Out-Host
Expand Down Expand Up @@ -176,17 +176,17 @@ test_script:
if ( "$Env:CMAKE_GEN" -ieq "MinGW32" ) {
echo "$Env:MSYS2_PREFIX/msys2_shell -mingw32 -lc cd '$Env:APPVEYOR_BUILD_FOLDER/build'; ./test/coroutine_test.exe;"
echo "$Env:MSYS2_PREFIX/msys2_shell -mingw32 -lc cd '$Env:APPVEYOR_BUILD_FOLDER/build'; make unit_test benchmark;"
& "$Env:MSYS2_PREFIX/msys2_shell" -mingw32 -lc "cd '$Env:APPVEYOR_BUILD_FOLDER/build'; ./test/coroutine_test.exe > '$Env:MSYS2_LOG_FILE';" | Out-Host
& "$Env:MSYS2_PREFIX/msys2_shell" -mingw32 -lc "cd '$Env:APPVEYOR_BUILD_FOLDER/build'; make unit_test benchmark > '$Env:MSYS2_LOG_FILE';" | Out-Host
Get-Content "$Env:MSYS2_LOG_FILE"
} else {
echo "$Env:MSYS2_PREFIX/msys2_shell -mingw64 -lc cd '$Env:APPVEYOR_BUILD_FOLDER/build'; ./test/coroutine_test.exe;"
echo "$Env:MSYS2_PREFIX/msys2_shell -mingw64 -lc cd '$Env:APPVEYOR_BUILD_FOLDER/build'; make unit_test benchmark;"
& "$Env:MSYS2_PREFIX/msys2_shell" -mingw64 -lc "cd '$Env:APPVEYOR_BUILD_FOLDER/build'; ./test/coroutine_test.exe > '$Env:MSYS2_LOG_FILE';" | Out-Host
& "$Env:MSYS2_PREFIX/msys2_shell" -mingw64 -lc "cd '$Env:APPVEYOR_BUILD_FOLDER/build'; make unit_test benchmark > '$Env:MSYS2_LOG_FILE';" | Out-Host
Get-Content "$Env:MSYS2_LOG_FILE"
Expand All @@ -196,6 +196,8 @@ test_script:
& "test/$Env:CONFIGURATION/coroutine_test.exe"
& "../doc/reports/windows_start_benchmark.bat"
}
#
Expand Down
26 changes: 22 additions & 4 deletions doc/md/000_DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
libcopp
=======
> cross-platform coroutine library of c++
>

> cross-platform coroutine library in c++
>
> in developing ...
>
> Build & Run Unit Test in | Linux+OSX(Clang+GCC) | Windows(VC+MinGW) |
> -------------------------|-----------------------|-------------|
> Status | [![Build Status](https://travis-ci.org/owt5008137/libcopp.svg?branch=master)](https://travis-ci.org/owt5008137/libcopp) | [![Build status](https://ci.appveyor.com/api/projects/status/7w6dfnpeahfmgaqj?svg=true)](https://ci.appveyor.com/project/owt5008137/libcopp) |
> Compilers | linux-gcc-4.4 <br /> linux-gcc-4.6 <br /> linux-gcc-4.9 <br /> linux-gcc-6 <br /> linux-clang-3.5 <br /> osx-apple-clang-6.0 <br /> | MSVC 12(Visual Studio 2013) <br /> MSVC 14(Visual Studio 2015) <br /> MinGW64-gcc
>

Gitter
------
[![Gitter](https://badges.gitter.im/owt5008137/libcopp.svg)](https://gitter.im/owt5008137/libcopp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

LICENSE
-------

## LICENSE
License under the MIT license

## Document
Document
--------

Generate document with doxygen.

Doxygen file located at *doc/libcopp.doxyfile* .


53 changes: 34 additions & 19 deletions doc/md/010_INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,63 @@
# INSTALL
INSTALL
=======

> libcopp use cmake to generate makefile and switch build tools.
## Prerequisites
+ **[required]** GCC or Clang or VC support ISO C++ 98 and upper
+ **[required]** [cmake](www.cmake.org) 2.8.9 and upper
+ **[optional]** [gtest](https://code.google.com/p/googletest/) 1.6.0 and upper (better test supported)
Prerequisites
-------------

### Unix
* **[required]** ar, as, ld ([binutils](http://www.gnu.org/software/binutils/))
* **[optional]** if using [gtest](https://code.google.com/p/googletest/), pthread is required.
- **[required]** GCC or Clang or VC support ISO C++ 03 and upper
- **[required]** [cmake](www.cmake.org) 3.1.0 and upper
- **[optional]** [gtest](https://code.google.com/p/googletest/) 1.6.0 and upper (better test supported)
- **[optional]** [Boost.Test](http://www.boost.org/doc/libs/release/libs/test/) (Boost.Test supported)

### Unix

- **[required]** ar, as, ld ([binutils](http://www.gnu.org/software/binutils/))
- **[optional]** if using [gtest](https://code.google.com/p/googletest/), pthread is required.

### Windows
* **[required]** masm (in vc)
* **[optional]** if using [gtest](https://code.google.com/p/googletest/), pthread is required.

- **[required]** masm (in vc)
- **[optional]** if using [gtest](https://code.google.com/p/googletest/), pthread is required.

Build
-----

## Build
**1. make a build directory**

mkdir build

**2. run cmake command**

cmake <libcopp dir> [options]
> options can be cmake options. such as set compile toolchains, source directory or options of libcopp that control build actions.
> libcopp options are listed below:

>> -DBUILD_SHARED_LIBS=YES|NO [default=NO] enable build dynamic library.
> options can be cmake options. such as set compile toolchains, source directory or options of libcopp that control build actions. libcopp options are listed below:
> > -DBUILD\_SHARED\_LIBS=YES|NO [default=NO] enable build dynamic library.
>> -DLIBCOPP_ENABLE_SEGMENTED_STACKS=YES|NO [default=NO] enable split stack supported context.(it's only availabe in linux and gcc 4.7.0 or upper)
> > -DLIBCOPP\_ENABLE\_SEGMENTED\_STACKS=YES|NO [default=NO] enable split stack supported context.(it's only availabe in linux and gcc 4.7.0 or upper)
>> -DGTEST_ROOT=[path] set gtest library install prefix path
> > -DLIBCOPP\_ENABLE\_VALGRIND=YES|NO [default=YES] enable valgrind supported context.
> > -DGTEST\_ROOT=[path] set gtest library install prefix path
**3. make libcopp**

make [options]

**4. run test** *[optional]*

test/coroutine_test
make unit_test

**5. run benchmark** *[optional]*

make benchmark

**5. install** *[optional]*
**6. install** *[optional]*

make install

> Or you can just copy include directory and libcopp.a in lib or lib64 into your project to use it.

29 changes: 17 additions & 12 deletions doc/md/020_USAGE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# USAGE
USAGE
=====

> Just include headers and linking library file of your platform to use libcopp
## Example
Example
-------

### coroutine_context example
There is a simple example of using coroutine context below:

Expand Down Expand Up @@ -60,7 +63,7 @@ And then, you can custom many function such as set your stack allocator, corouti


### coroutine task example
There is also a simple example of using coroutine task below:
There is a simple example of using coroutine task below:

``` {.cpp}
#include <iostream>
Expand All @@ -72,22 +75,24 @@ typedef cotask::task<> my_task_t;
int main(int argc, char* argv[]) {
// create a task using factory function [with lambda expression]
my_task_t::prt_t task = my_task_t::create([](){
std::cout<< "task "<< cotask::this_task::get_task()->get_id()<< " started"<< std::endl;
my_task_t::prt_t task = my_task_t::create([](){
std::cout<< "task "<< cotask::this_task::get_task()->get_id()<< " started"<< std::endl;
cotask::this_task::get_task()->yield();
std::cout<< "task "<< cotask::this_task::get_task()->get_id()<< " resumed"<< std::endl;
return 0;
std::cout<< "task "<< cotask::this_task::get_task()->get_id()<< " resumed"<< std::endl;
return 0;
});
std::cout<< "task "<< task->get_id()<< " created"<< std::endl;
std::cout<< "task "<< task->get_id()<< " created"<< std::endl;
// start a task
task->start();
std::cout<< "task "<< task->get_id()<< " yield"<< std::endl;
task->resume();
std::cout<< "task "<< task->get_id()<< " stoped, ready to be destroyed."<< std::endl;
std::cout<< "task "<< task->get_id()<< " yield"<< std::endl;
task->resume();
std::cout<< "task "<< task->get_id()<< " stoped, ready to be destroyed."<< std::endl;
return 0;
}
```
And then, you can custom many functions by set your macro type of coroutine and task to do some other function.


5 changes: 3 additions & 2 deletions doc/md/050_NOTICE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# NOTICE
split stack support: if in Linux and user gcc 4.7.0 or upper, add -DLIBCOPP_ENABLE_SEGMENTED_STACKS=YES to use split stack supported context.
NOTICE
======

split stack support: if in Linux and user gcc 4.7.0 or upper, add -DLIBCOPP\_ENABLE\_SEGMENTED\_STACKS=YES to use split stack supported context.

5 changes: 2 additions & 3 deletions doc/md/060_DEVELOPER.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# DEVELOPER
DEVELOPER
=========

[basic coroutine object summary](doc/basic_coroutine_class.txt)

[safe coroutine object summary](doc/safe_basic_coroutine_class.txt)



Loading

0 comments on commit e738c26

Please sign in to comment.