性能测试:
使用st对服务器程序分别在FreeBSD和windows(Cygwin)下的运行情况进行测试(st相应的运行在FreeBSD和Cygwin下)。
机器硬件条件:Intel (R) Celeron CPU 2.40GHz;256DDR,Maxtor 80G。
1. FreeBSD 4.7环境:
/*****************************************************/
www# ./st -n 100 -c 20 192.168.1.7/123
This is ServerTest for my pngserver, Version 1.0
Copyright (C) 2004-2005 XiongBin Xiong All rights reserved
testing...
Server Hostname: 192.168.1.7
Server Port: 80
Document Path: /123
Total Requests: 100
Concurrency Level: 20
Time taken for tests: 0.709739 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 35000 Bytes
Requests per second: 140.90 [#/sec] (mean)
Time per request: 141.948 [ms] (mean)
Time per request: 7.097 [ms] (mean, across all concurrent requests)
Transfer rate: 48.16 [Kbytes/sec] received
/*************************************************************/
2. Windows XP (Cygwin)环境:
/*****************************************************/
testing...This is ServerTest for my pngserver, Version 1.0
Copyright (C) 2004-2005 XiongBin Xiong All rights reserved
testing...
Server Hostname: 192.168.1.7
Server Port: 80
Document Path: /qwe
Total Requests: 50
Concurrency Level: 5
Time taken for tests: 39.487579 seconds
Complete requests: 50
Failed requests: 0
Total transferred: 7900 Bytes
Requests per second: 1.27 [#/sec] (mean)
Time per request: 3948.758 [ms] (mean)
Time per request: 789.752 [ms] (mean, across all concurrent requests)
Transfer rate: 0.20 [Kbytes/sec] received
/****************************************************/
当并发数为5时,程序正常。
/*****************************************************/
testing...This is ServerTest for my pngserver, Version 1.0
Copyright (C) 2004-2005 XiongBin Xiong All rights reserved
connect error
connect error
connect error
connect error
connect error
connect error
connect error
Server Hostname: 192.168.1.7
Server Port: 80
Document Path: /qwe
Total Requests: 50
Concurrency Level: 10
Time taken for tests: 29.208741 seconds
Complete requests: 43
Failed requests: 7
Total transferred: 6794 Bytes
Requests per second: 1.47 [#/sec] (mean)
Time per request: 6792.730 [ms] (mean)
Time per request: 679.273 [ms] (mean, across all concurrent requests)
Transfer rate: 0.23 [Kbytes/sec] received
/****************************************************/
当并发数为10时,程序出现连接失败情况。
/*****************************************************/
testing...This is ServerTest for my pngserver, Version 1.0
Copyright (C) 2004-2005 XiongBin Xiong All rights reserved
connect error
connect error
......
connect error
Server Hostname: 192.168.1.7
Server Port: 80
Document Path: /qwe
Total Requests: 100
Concurrency Level: 20
Time taken for tests: 30.19982 seconds
Complete requests: 54
Failed requests: 46
Total transferred: 12802 Bytes
Requests per second: 1.80 [#/sec] (mean)
Time per request: 11110.512 [ms] (mean)
Time per request: 555.926 [ms] (mean, across all concurrent requests)
Transfer rate: 0.42 [Kbytes/sec] received
/****************************************************/
当并发数为20时,程序出现大量连接失败情况。
简单分析:
程序运行于Cygwin环境时性能大大低于FreeBSD环境,特别是服务器程序和测试程序同时运行于Cygwin环境时;
st程序中使用的各种函数如:strcpy,strcat,strchr,strstr等,都可能对性能造成影响,即,可能是在测试ab而不是服务器的性能。