Skip to content

Commit

Permalink
feat: add benchtest for filelogger
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxuan520 committed Nov 26, 2024
1 parent f6189c0 commit ac9cab7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
6 changes: 4 additions & 2 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,11 @@ cppnet
├── string.hpp
├── threadpool.cpp
├── threadpool.hpp
└── trie.hpp
├── trie.hpp
├── version.cpp
└── version.hpp
18 directories, 58 files
19 directories, 60 files
```
### Class Diagram
![](http://cdn.androidftp.top/test/2024111122224337cppnet.drawio.png)
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,11 @@ cppnet
├── string.hpp
├── threadpool.cpp
├── threadpool.hpp
└── trie.hpp
├── trie.hpp
├── version.cpp
└── version.hpp
18 directories, 58 files
19 directories, 60 files
```
### 类关系图
![](http://cdn.androidftp.top/test/2024111122224337cppnet.drawio.png)
Expand Down
2 changes: 1 addition & 1 deletion demo/simple-http-server/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
mkdir -p ../bin
mkdir -p ../pack/simple-http-server
rm ./demo
rm ../bin/demo

mkdir -p build
cd build
Expand Down
1 change: 1 addition & 0 deletions demo/simple-http-server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using namespace std;

int main() {
HttpServer server;
// server.server().set_mode(TcpServer::kMixed);
auto rc = server.Init({"127.0.0.1", 8080});
// auto ssl_context = make_shared<SSLContext>();
// auto rc =
Expand Down
11 changes: 11 additions & 0 deletions src/test/log/file_logger_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,14 @@ TEST(FileLogger, FirstWrite) {
MUST_TRUE(count == write_time * 5,
to_string(count) + " != " + to_string(write_time * 5));
}

BENCHMARK(FileLogger, WriteRate) {
const std::string file_path = "file_benct_test.log";
const std::string write_msg = "[test]:test-for-benchmark";
auto logger = std::make_shared<FileLogger>();
logger->Init(file_path);

DEFER_DEFAULT { File::Remove(file_path); };

BENCHFUNC([&]() { logger->Debug(write_msg); });
}
2 changes: 1 addition & 1 deletion src/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ INIT(Main) {

GO([&]() {
// max run time
sleep(10);
sleep(15);
WARNING("Test Task Cost Too Much Time, Killed");
exit(-1);
});
Expand Down

0 comments on commit ac9cab7

Please sign in to comment.