问题: 编写一个 ab(Apache Benchmark) 的替代程序,请尽可能的兼容 ab 你所认为重要的功能和参数。
ab [options] http://hostname[:port][/path]
-n requests number of requests to perform
-c concurrency number of multiple requests to make
-t timelimit seconds to max. wait for responses
-i use HEAD instead of GET
-v verbose
代码在这里: https://github.com/YangXin/ab
使用它: 切换到 ab 的目录直接 make , 然后尝试一下 ./ab -c 20 -n 100 http://blog.csdn.net/johnstrive/article/details/50667557
注意:
1 、在计算一些数据大小的时候我与 ab 有一些不同, 我没有研究 ab 内部实现,但是这些区别不影响我们对结果分析
- 在计算 transfer data 的时候, 我计算从 TCP 拿到的所有数据
- 在计算 html data 的时候, 我计算 http 的 payload
2 、对于 http 协议我也是只实现了一个子集, 我实现了基本的 chunked 模式和 content-length
PS :各位同行有后台开发坑位没, 联系方式 [email protected]