Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/server_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ jobs:
conan_audit_token: ${{ secrets.CONAN_AUDIT_TOKEN }}

- name: Install Conan dependencies
run: conan build . --build=missing
run: conan build . --build=missing -s build_type=Debug

- name: Run GTest
run: ctest --test-dir build/Release
run: ctest --test-dir build/Debug

- name: Coverage
shell: bash
run: |
cd build/Release
cd build/Debug
make coverage

- name: Report Code Coverage
uses: zgosalvez/github-actions-report-lcov@v4
with:
coverage-files: build/Release/CMakeFiles/server_library.dir/src/coverage.info
coverage-files: build/Debug/CMakeFiles/server_library.dir/src/coverage.info
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ set(TEST_TARGET "server_tests_bin")
set(TARGET "server_impl_bin")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Override Debug flags
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 --coverage")
set(CMAKE_C_FLAGS_DEBUG "-g -O0 --coverage")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "--coverage")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "--coverage")

find_package(GTest CONFIG REQUIRED)
find_package(Threads REQUIRED)

Expand All @@ -24,34 +30,31 @@ add_library(${LIBRARY}
)
target_include_directories(${LIBRARY} PUBLIC include)
target_compile_features(${LIBRARY} PRIVATE cxx_std_17)
target_compile_options(${LIBRARY} PRIVATE -O0 -g --coverage)
target_link_libraries(${LIBRARY} PRIVATE Threads::Threads)


# unit tests executable
enable_testing()
add_executable(${TEST_TARGET}
test/HttpServerTest.cpp
test/HttpParserTest.cpp
test/HttpServerTest.cpp
test/HttpParserTest.cpp
)
target_link_libraries(${TEST_TARGET}
PRIVATE ${LIBRARY} GTest::gtest_main
)

include(GoogleTest)
gtest_discover_tests(${TEST_TARGET})
target_compile_options(${TEST_TARGET} PRIVATE -g -O0 -g --coverage)
target_link_options(${TEST_TARGET} PRIVATE -O0 -g --coverage)


# server implementation executable
add_executable(${TARGET}
src/main.cpp
)
target_compile_options(${TARGET} PRIVATE -g -O0 -g --coverage)
target_link_options(${TARGET} PRIVATE -O0 -g --coverage)
target_link_libraries(${TARGET} PRIVATE ${LIBRARY})


# coverage target
# find required tools
find_program(LCOV lcov REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ WORKDIR /app
COPY --exclude=build/ . .

# Build with Conan
RUN conan build . --build=missing
RUN conan build . --build=missing -s build_type=Release


CMD ["/bin/bash"]
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ A modern C++ HTTP server implementation with routing, testing, and CI-driven qua
* [Using Nix](#using-nix)
* [Building the Source Code](#building-the-source-code)
* [Building for Release Mode](#building-for-release-mode)
* [Building for Debug Mode](#building-for-debug-mode)
* [Running the Server](#running-the-server)
* [Running the Tests](#running-the-tests)
* [Code Coverage](#code-coverage)
Expand Down Expand Up @@ -77,7 +78,7 @@ The cpp_http_server is ~1.562x faster in throughput or about 56.2% higher reques
Calculation: 27,366.734925 RPS / 17,524.167725 RPS = ~1.5612

| Metric | **C++ Server** | **Node + Express** |
| ------------------ | ----------------- | ------------------ |
|--------------------|-------------------|--------------------|
| Target rate | 30,000.00 RPS | 30,000.00 RPS |
| Actual RPS | 27,366.734925 RPS | 17,524.167725 RPS |
| Total requests | 280,791 | 176,924 |
Expand Down Expand Up @@ -171,7 +172,13 @@ This project uses **Conan** for dependency management and **CMake** for builds.
### Building for Release Mode

```bash
conan build . --build=missing
conan build . --build=missing -s build_type=Release
```

### Building for Debug Mode

```bash
conan build . --build=missing -s build_type=Debug
```

---
Expand All @@ -183,6 +190,9 @@ Command to run the HTTP server implementation example:
```bash
# in release mode
./build/Release/server_impl_bin

# in debug mode
./build/Debug/server_impl_bin
```

---
Expand All @@ -193,7 +203,7 @@ Command to execute the automated test suite:

```bash
# run tests
./build/Release/server_tests_bin
./build/Debug/server_tests_bin
```

---
Expand All @@ -205,14 +215,14 @@ Coverage reports are generated using **lcov**.
### Generate Coverage Reports

```bash
make -C build/Release coverage
make -C build/Debug coverage
```

### Open the Coverage Report

```bash
# specific to Linux
xdg-open build/Release/CMakeFiles/server_library.dir/src/out/index.html
xdg-open build/Debug/CMakeFiles/server_library.dir/src/out/index.html
```

---
Expand Down
Loading