php yac使用,php yac简单压测

个人PC!4G内存,双核CPU

1、即写又读压测

$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

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、只写压测

$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

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、只读压测

$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

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、为什么写比读还快呢,性能还好呢?

2、1000个KEY有4个KEY的失败,返回null

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
帮我优化一下这段代码(select uuid() as id , a.customerCode as customerCode , a.customerName as customerName , a.unifiedSocialCreditCode as unifiedSocialCreditCode , a.firstInsuranceCode as firstInsuranceCode , a.firstInsuranceName as firstInsuranceName , a.firstRiskCode as firstRiskCode , a.firstRiskName as firstRiskName , a.secondRiskCode as secondRiskCode, a.secondRiskName as secondRiskName, cast(a.secondRiskBasicScore as DECIMAL(6,2)) as secondRiskBasicScore , cast(a.secondRiskBasicScore as DECIMAL(6,2)) as secondRiskScore , to_date(date_add(now(),-1)) as createDate from ( select a.customerCode, a.customerName, a.unifiedSocialCreditCode,'ALL' AS firstInsuranceCode,'全险种' AS firstInsuranceName,c.firstRiskCode,c.firstRiskName,c.secondRiskCode,c.secondRiskName, sum((case when (a.POLICYSTATUS = 'A') then a.sumAssured when (a.POLICYSTATUS = 'B') then (a.PAYOUT+a.OUTSTANDING) else a.sumAssured end) / b.AllcustomersumAssured * c.secondRiskScore) as secondRiskBasicScore from ccic_fkyjrisk.FocusCustomerPolicyData a join ccic_fkyjrisk_orig.InsuranceProductGroup d on d.scoreCardType='0' and a.insuranceCode = d.insuranceCode join ccic_fkyjrisk.PolicyRiskSecondScore c on a.customerCode = c.customerCode and a.policycode=c.policycode and firstRiskCode = '002' join ccic_fkyjrisk.TargetcustomerRanking b on b.firstInsuranceCode ='ALL' and a.customerCode = b.customerCode where (case when (a.POLICYSTATUS = 'A') then a.sumAssured when (a.POLICYSTATUS = 'B') then (a.PAYOUT+a.OUTSTANDING) else a.sumAssured end)>0 and length(nvl(cast((case when (a.POLICYSTATUS = 'A') then a.sumAssured when (a.POLICYSTATUS = 'B') then (a.PAYOUT+a.OUTSTANDING) else a.sumAssured end) as string),''))>0 and (a.firstInsuranceName!='健康险' and a.insuranceCode not in('5IE','5VA','5XA','5XC','5XE','EFD','EFM','EFW','EGB','EGM', 'EGZ','EIA','EIB','EIE','EIF','EIH','EIZ','ERQ','ERW','ERY','ERZ','ESZ','ETB','ETC', 'ETR','ETX','ETZ','EVA','EVB','EXA','EXB','EXE','EYM','4DJ','EGD','5GD','ZCJ','ZCF') and a.secondInsuranceName not in('家庭财产保险','农业保险') and a.insuranceCode not like 'YEE%' and a.insuranceCode not like 'YAC%') group by a.customerCode, a.customerName, a.unifiedSocialCreditCode,c.firstRiskCode,c.firstRiskName,c.secondRiskCode,c.secondRiskName) a;)
06-08

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值