怎么進(jìn)行java并發(fā)模擬,很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
為石景山等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及石景山網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、石景山網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
在project-1中新建controller,TestController.java內(nèi)容如下:
@RestController @Slf4j public class TestController { @GetMapping("/test") public String test() { return "test"; } }
需要依賴Slf4j包,需要在pom.xml文件中添加依賴:
org.projectlombok lombok 1.18.6
在postman工具中新建collection:
并將測(cè)試url添加到這個(gè)collection中,點(diǎn)擊run,然后配置:
下載地址:https://www.apachelounge.com/download/
ab -n 1000 -c 50 http://localhost:8080/test
輸出結(jié)果如下:
C:\Users\vincent>ab -n 1000 -c 50 http://localhost:8080/test This is ApacheBench, Version 2.3 <$Revision: 1843412 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests Server Software: Server Hostname: localhost Server Port: 8080 Document Path: /test Document Length: 4 bytes Concurrency Level: 50 Time taken for tests: 0.673 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 136000 bytes HTML transferred: 4000 bytes Requests per second: 1486.74 [#/sec] (mean) Time per request: 33.631 [ms] (mean) Time per request: 0.673 [ms] (mean, across all concurrent requests) Transfer rate: 197.46 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.3 0 1 Processing: 1 19 19.8 15 291 Waiting: 0 16 16.7 12 278 Total: 1 20 19.8 15 292 Percentage of the requests served within a certain time (ms) 50% 15 66% 19 75% 23 80% 24 90% 33 95% 62 98% 84 99% 99 100% 292 (longest request)
-n 1000表示本次測(cè)試的總數(shù)為100個(gè)
-c 50表示本次請(qǐng)求的并發(fā)數(shù)是50
看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。