Skip to content

Commit

Permalink
feat:add bench cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxuan520 committed Nov 25, 2024
1 parent 2cb4f83 commit bc07d7b
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 14 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- master
paths:
- 'docs/**'
- 'bench/**'
- '.github/workflows/docs.yml'
- 'README.md'
- 'README.en.md'
Expand All @@ -27,6 +28,17 @@ jobs:
mv ./cppnet/README.md Home.md
mv ./cppnet/README.en.md .
cd ..
- name: Run Benchtest
run: |
cd ./bench
./init.sh
./build.sh
python3 ./plot.py
mkdir -p ../book/img
mv ./result.png ../book/img/
cd ..
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ bin
build
pack
compile_commands.json
metrics*
*.png
.cache
test_bin
.clangd
Expand Down
25 changes: 22 additions & 3 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,38 @@ int main() {
- build.sh generates the lib static library and the unit test binary file
- docs is the interface documentation
- demo is the reference example
- bench is the benchmark
```tree
.
├── LICENSE
├── README.en.md
├── README.md
├── bench
│   ├── build.sh
│   └── init.sh
├── demo
│   ├── asset
│   ├── build.sh
│   ├── mnist
│   ├── pack
│   ├── simple-http-server
│   ├── use-lib-server
│   ├── use-lib-server-ssl
│   ├── util
│   └── web-server
├── docs
│   ├── cppnet
│   └── update.sh
└── src
├── build.sh
├── CMakeLists.txt
├── build.sh
├── cppnet
├── lib
├── release.sh
├── test
└── third_party
├── third_party
└── win_release.sh
```
- The source code is mainly placed in `src/cppnet`.
```txt
Expand Down Expand Up @@ -372,4 +392,3 @@ cppnet
```
### Class Diagram
![](http://cdn.androidftp.top/test/2024111122224337cppnet.drawio.png)
## TODO
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,38 @@ int main() {
- build.sh 生成 lib 静态库以及 单元测试的二进制文件
- docs 是接口文档
- demo 是参考的事例
- bench 是性能测试
```tree
.
├── LICENSE
├── README.en.md
├── README.md
├── bench
│   ├── build.sh
│   └── init.sh
├── demo
│   ├── asset
│   ├── build.sh
│   ├── mnist
│   ├── pack
│   ├── simple-http-server
│   ├── use-lib-server
│   ├── use-lib-server-ssl
│   ├── util
│   └── web-server
├── docs
│   ├── cppnet
│   └── update.sh
└── src
├── build.sh
├── CMakeLists.txt
├── build.sh
├── cppnet
├── lib
├── release.sh
├── test
└── third_party
├── third_party
└── win_release.sh
```
- 源码主要放置在 `src/cppnet`
```txt
Expand Down Expand Up @@ -393,5 +413,5 @@ cppnet
- [x] 支持SSL
- [x] accept 改造
- [x] 完善多线程
- [ ] 添加压力测试
- [x] 添加压力测试
- [ ] 提升trie
File renamed without changes.
2 changes: 2 additions & 0 deletions demo/asset/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
git clone --depth=1 https://github.com/wuhobin/blog-home
12 changes: 12 additions & 0 deletions demo/simple-http-server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ set(CMAKE_CXX_STANDARD 17)

set(ENABLE_SSL ON)
add_definitions(-DCPPNET_OPENSSL)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(OPENSSL_VERSION "")
execute_process(
COMMAND brew list --versions openssl
OUTPUT_VARIABLE OPENSSL_VERSION_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" OPENSSL_VERSION "${OPENSSL_VERSION_OUTPUT}")

include_directories(/opt/homebrew/Cellar/openssl@3/${OPENSSL_VERSION}/include)
link_directories(/opt/homebrew/Cellar/openssl@3/${OPENSSL_VERSION}/lib)
endif()
# link_libraries(-lssl -lcrypto)

add_subdirectory(../../src/lib cppnet)
Expand Down
4 changes: 2 additions & 2 deletions demo/simple-http-server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ int main() {
ctx.resp().Redirect("https://chenxuanweb.top");
});

server.StaticDir("/", "./blog-home");
server.StaticFile("/", "./blog-home/index.html");
server.StaticFile("/", "../asset/index.html");
server.StaticDir("/", "../asset/blog-home/");

rc = server.Run();
if (rc != 0) {
Expand Down
12 changes: 6 additions & 6 deletions demo/web-server/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"port":5200,
"port":8080,
"host":"127.0.0.1",
"is_background":false,
"is_guard":false,
Expand All @@ -13,19 +13,19 @@
"statics":[
{
"route":"/",
"path":"./index.html"
"path":"../asset/index.html"
},
{
"route":"/home",
"path":"./blog-home/index.html"
"path":"../asset/blog-home/index.html"
},
{
"route":"/",
"path":"./blog-home"
"path":"../asset/blog-home"
}
],
"ssl":{
"cert_path":"./ssl/cert_demo.pem",
"key_path":"./ssl/cert_key.pem"
"cert_path":"./ssl/cacert.pem",
"key_path":"./ssl/privkey.pem"
}
}
8 changes: 8 additions & 0 deletions demo/web-server/init.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
#!/bin/bash
git clone https://gitee.com/chenxuan520/cppjson

# if not exist ssl dir
if [ ! -d "./ssl" ]; then
mkdir ssl
cd ssl
# openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout privkey.pem -out cacert.pem -days 3650
openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout privkey.pem -out cacert.pem -days 3650 -subj '/C=US/ST=YourState/L=YourCity/O=YourOrganization/OU=YourUnit/CN=example.com'
fi

0 comments on commit bc07d7b

Please sign in to comment.