php yac简单压测

个人PC4G内存,双核CPU

1、即写又读压测

<?php

$yac= new Yac();

for($i = 0; $i<1000; $i++) {

$key= "xxx". $i;

$value= str_repeat("x", $i);

if(!$yac->set($key, $value)) {

var_dump("write" . $i);

}

if($value != ($new = $yac->get($key))) {

var_dump("read" . $i);

}

}

var_dump($i);

linuxmintyac-master # ab -n 10000 -c 50 http://localhost/yac.php

Thisis ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensedto The Apache Software Foundation, http://www.apache.org/


Benchmarkinglocalhost (be patient)

Completed1000 requests

Completed2000 requests

Completed3000 requests

Completed4000 requests

Completed5000 requests

Completed6000 requests

Completed7000 requests

Completed8000 requests

Completed9000 requests

Completed10000 requests

Finished10000 requests



ServerSoftware: Apache/2.2.22

ServerHostname: localhost

ServerPort: 80


DocumentPath: /yac.php

DocumentLength: 98 bytes


ConcurrencyLevel: 50

Timetaken for tests: 138.244 seconds

Completerequests: 10000

Failedrequests: 6897

(Connect:0, Receive: 0, Length: 6897, Exceptions: 0)

Writeerrors: 0

Totaltransferred: 4499492 bytes

HTMLtransferred: 2382595 bytes

Requestsper second: 72.34 [#/sec] (mean)

Timeper request: 691.222 [ms] (mean)

Timeper request: 13.824 [ms] (mean, across all concurrent requests)

Transferrate: 31.78 [Kbytes/sec] received


ConnectionTimes (ms)

min mean[+/-sd] median max

Connect: 0 0 0.1 0 2

Processing: 25 691 150.3 694 1403

Waiting: 25 653 139.1 657 1343

Total: 25 691 150.2 694 1403


Percentageof the requests served within a certain time (ms)

50% 694

66% 753

75% 792

80% 813

90% 869

95% 919

98% 981

99% 1032

100% 1403 (longest request)


2、只写压测

<?php

$yac= new Yac();

for($i = 0; $i<1000; $i++) {

$key= "xxx". $i;

$value= str_repeat("x", $i);

var_dump($yac->set($key,$value));

}

var_dump($i);

linuxmintyac-master # ab -n 10000 -c 50 http://localhost/yac.php

Thisis ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensedto The Apache Software Foundation, http://www.apache.org/


Benchmarkinglocalhost (be patient)

Completed1000 requests

Completed2000 requests

Completed3000 requests

Completed4000 requests

Completed5000 requests

Completed6000 requests

Completed7000 requests

Completed8000 requests

Completed9000 requests

Completed10000 requests

Finished10000 requests



ServerSoftware: Apache/2.2.22

ServerHostname: localhost

ServerPort: 80


DocumentPath: /yac.php

DocumentLength: 102098 bytes


ConcurrencyLevel: 50

Timetaken for tests: 87.220 seconds

Completerequests: 10000

Failedrequests: 0

Writeerrors: 0

Totaltransferred: 1022890000 bytes

HTMLtransferred: 1020980000 bytes

Requestsper second: 114.65 [#/sec] (mean)

Timeper request: 436.100 [ms] (mean)

Timeper request: 8.722 [ms] (mean, across all concurrent requests)

Transferrate: 11452.82 [Kbytes/sec] received


ConnectionTimes (ms)

min mean[+/-sd] median max

Connect: 0 0 0.1 0 2

Processing: 15 436 130.0 433 903

Waiting: 1 27 64.8 3 369

Total: 15 436 130.0 433 904


Percentageof the requests served within a certain time (ms)

50% 433

66% 490

75% 523

80% 544

90% 599

95% 651

98% 706

99% 741

100% 904 (longest request)


3、只读压测

<?php

$yac= new Yac();

for($i = 0; $i<1000; $i++) {

$key= "xxx". $i;

$value= str_repeat("x", $i);

var_dump($yac->get($key));

}

var_dump($i);


linuxmintyac-master # ab -n 10000 -c 50 http://localhost/yac.php

Thisis ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensedto The Apache Software Foundation, http://www.apache.org/


Benchmarkinglocalhost (be patient)

Completed1000 requests

Completed2000 requests

Completed3000 requests

Completed4000 requests

Completed5000 requests

Completed6000 requests

Completed7000 requests

Completed8000 requests

Completed9000 requests

Completed10000 requests

Finished10000 requests



ServerSoftware: Apache/2.2.22

ServerHostname: localhost

ServerPort: 80


DocumentPath: /yac.php

DocumentLength: 499742 bytes


ConcurrencyLevel: 50

Timetaken for tests: 126.988 seconds

Completerequests: 10000

Failedrequests: 0

Writeerrors: 0

Totaltransferred: 4999330000 bytes

HTMLtransferred: 4997420000 bytes

Requestsper second: 78.75 [#/sec] (mean)

Timeper request: 634.939 [ms] (mean)

Timeper request: 12.699 [ms] (mean, across all concurrent requests)

Transferrate: 38445.90 [Kbytes/sec] received


ConnectionTimes (ms)

min mean[+/-sd] median max

Connect: 0 0 0.1 0 2

Processing: 23 634 197.1 634 1578

Waiting: 1 24 85.3 1 597

Total: 23 634 197.1 634 1578


Percentageof the requests served within a certain time (ms)

50% 634

66% 722

75% 771

80% 802

90% 882

95% 950

98% 1019

99% 1068

100% 1578 (longest request)


总结:

1、为什么写比读还快呢,性能还好呢?

21000KEY4KEY的失败,返回null


你可能感兴趣的:(PHP,yac)