# maplec **Repository Path**: cen-code/maplec ## Basic Information - **Project Name**: maplec - **Description**: netlib - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-27 - **Last Updated**: 2025-11-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: Cpp, Linux ## README ## maplec **maplec = maple(🍁) + c(cen&c++)** 本项目是在参考`muduo`源码的基础上,使用 C++11 对 muduo 网络库核心进行了重构,并根据 muduo 的设计思想,基于多 Reactor 多线程模型的网络库来实现。基于非阻塞IO和事件驱动的C++高并发TCP网络库,使用的线程模型是`one loop per thread`。用于个人学习和记录。 ## 使用 ```sh # 1. 下载 # ssh git clone git@gitee.com:cen-code/maplec.git # https git clone https://gitee.com/cen-code/maplec.git ``` 在网络库基础上。实现了一个简单的Http服务: ```sh # 1. 执行程序 cd source/http make ./Main # 2. 浏览器访问 ip:8080,访问首页,进行后续测试 ``` ## 压力测试 ```sh ab -t 30 -c 500 -k http://127.0.0.1:8080/ # ... Benchmarking 127.0.0.1 (be patient) Completed 5000 requests Completed 10000 requests Completed 15000 requests Completed 20000 requests Completed 25000 requests Finished 25175 requests Server Software: Server Hostname: 127.0.0.1 Server Port: 8080 Document Path: / Document Length: 4746 bytes Concurrency Level: 500 Time taken for tests: 30.059 seconds Complete requests: 25175 Failed requests: 0 Keep-Alive requests: 25175 Total transferred: 121746300 bytes HTML transferred: 119480550 bytes Requests per second: 837.52 [#/sec] (mean) Time per request: 597.000 [ms] (mean) Time per request: 1.194 [ms] (mean, across all concurrent requests) Transfer rate: 3955.33 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 5 71.7 0 1039 Processing: 3 269 552.0 240 22150 Waiting: 3 269 552.0 240 22150 Total: 3 274 598.3 240 23187 Percentage of the requests served within a certain time (ms) 50% 240 66% 256 75% 276 80% 292 90% 348 95% 376 98% 449 99% 570 100% 23187 (longest request) ``` 测试环境:服务器为2核2G,创建了一个主 Reactor 线程,三个从 Reactor 线程,Apache Bench工具进行测试 测试结果: - 每秒处理837.52个请求 - 每个请求平均耗时1.194毫秒