亚洲中字慕日产2020,大陆极品少妇内射AAAAAA,无码av大香线蕉伊人久久,久久精品国产亚洲av麻豆网站

資訊專(zhuān)欄INFORMATION COLUMN

基準(zhǔn)測(cè)試工具:ab

tianyu / 1279人閱讀

摘要:基準(zhǔn)測(cè)試工具是什么是基于命令行的工具,均可運(yùn)行在平臺(tái)下。即,用于指定壓力測(cè)試的并發(fā)數(shù)。添加一個(gè)基本的代理認(rèn)證信息,用戶名和密碼之間用英文冒號(hào)隔開(kāi)。打印版本號(hào)并退出。

基準(zhǔn)測(cè)試工具(ab)

ab是什么?
ab是基于命令行的工具,均可運(yùn)行在windows、linux平臺(tái)下。
為什么選用這個(gè)工具?
易于使用,輸入少量命令選項(xiàng),即可得出結(jié)果,同時(shí)易于安裝。

安裝ab

win:如果本地有apache的開(kāi)發(fā)環(huán)境,那么ab默認(rèn)在apache目錄下的bin目錄下,打開(kāi)bin目錄可以看到
linux:直接yum install httpd-tools,安裝即可

簡(jiǎn)單上手

直接敲入下面代碼(注意切換ab所在的目錄)
-c 10代表并發(fā)數(shù)是10
-n 10總共進(jìn)行100次訪問(wèn)
后面接要訪問(wèn)的網(wǎng)址,切記不可缺少http://

D:phpStudyApachein>ab -c 10 -n 1000 http://example.com/phpinfo.php

待ab自己跑一下,得出下面結(jié)果

#ab工具的描述,注意其中的版本號(hào)
This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

#測(cè)試結(jié)果,共測(cè)試1000次,每100次顯示訪問(wèn)進(jìn)度,訪問(wèn)的網(wǎng)站是example.com
Benchmarking example.com (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

#服務(wù)器的信息
Server Software:        nginx/1.6.2       #服務(wù)器web軟件
Server Hostname:        example.com       #主機(jī)地址
Server Port:            80                #訪問(wèn)端口

#文檔信息
Document Path:          /phpinfo.php      #訪問(wèn)的文檔
Document Length:        94804 bytes       #返回結(jié)果大小字節(jié)數(shù)(包含html,js,css,圖片及響應(yīng)中的所有內(nèi)容字節(jié)數(shù)總和)

#鏈接信息
Concurrency Level:      10                #并發(fā)數(shù),-c 10 設(shè)置了10個(gè)并發(fā)
Time taken for tests:   7.498 seconds     #總耗時(shí),單位秒
Complete requests:      1000              #總共請(qǐng)求中已完成的請(qǐng)求總數(shù)的和
Failed requests:        219               #失敗的請(qǐng)求數(shù)總和
   (Connect: 0, Receive: 0, Length: 219, Exceptions: 0)
Non-2xx responses:      9                 #未收到2xx系列成功的請(qǐng)求總數(shù)
Total transferred:      94135779 bytes    #整個(gè)請(qǐng)求總數(shù)中響應(yīng)總數(shù)距的總大小字節(jié)數(shù),包含頭信息
HTML transferred:       93952076 bytes    #整個(gè)請(qǐng)求總數(shù)中正文內(nèi)容的總大小字節(jié)
Requests per second:    133.36 [#/sec] (mean) #每秒支持的并發(fā)數(shù),這里是每秒支持133.36個(gè)并發(fā)
Time per request:       74.984 [ms] (mean)    #完成一個(gè)請(qǐng)求的總耗時(shí)
Time per request:       7.498 [ms] (mean, across all concurrent requests) #完成所有并發(fā)請(qǐng)求中一個(gè)請(qǐng)求的總耗時(shí)
Transfer rate:          12259.83 [Kbytes/sec] received #每秒收到的字節(jié)總數(shù)(KB)

#測(cè)試的時(shí)間結(jié)果數(shù)據(jù),留意Total一項(xiàng),10個(gè)并發(fā)的情況下,完成一個(gè)請(qǐng)求,最小耗時(shí)(min)9毫秒,最大耗時(shí)(max)146毫秒
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.7      0      20
Processing:     9   74  22.2     68     146
Waiting:        6   73  22.1     67     143
Total:          9   74  22.2     68     146

#完成請(qǐng)求百分比,例如第一項(xiàng),50%  68,代表一半的請(qǐng)求在68毫秒內(nèi)完成,95% 129,代表1000的請(qǐng)求里,百分之九十八的請(qǐng)求在129毫秒里完成
Percentage of the requests served within a certain time (ms)
  50%     68
  66%     78
  75%     86
  80%     92
  90%    109
  95%    122
  98%    129
  99%    133
 100%    146 (longest request)
ab選項(xiàng)

輸入下面命令得到ab幫助文檔,該幫助文檔,分別說(shuō)明了用法和命令選項(xiàng)的含義

D:phpStudyApachein>ab -h

ab幫助文檔的輸出

Usage: ab [options] [http://]hostname[:port]/path
Options are:
    -n requests     Number of requests to perform
    -c concurrency  Number of multiple requests to make at a time
    -t timelimit    Seconds to max. to spend on benchmarking
                    This implies -n 50000
    -s timeout      Seconds to max. wait for each response
                    Default is 30 seconds
    -b windowsize   Size of TCP send/receive buffer, in bytes
    -B address      Address to bind to when making outgoing connections
    -p postfile     File containing data to POST. Remember also to set -T
    -u putfile      File containing data to PUT. Remember also to set -T
    -T content-type Content-type header to use for POST/PUT data, eg.
                    "application/x-www-form-urlencoded"
                    Default is "text/plain"
    -v verbosity    How much troubleshooting info to print
    -w              Print out results in HTML tables
    -i              Use HEAD instead of GET
    -x attributes   String to insert as table attributes
    -y attributes   String to insert as tr attributes
    -z attributes   String to insert as td or th attributes
    -C attribute    Add cookie, eg. "Apache=1234". (repeatable)
    -H attribute    Add Arbitrary header line, eg. "Accept-Encoding: gzip"
                    Inserted after all normal header lines. (repeatable)
    -A attribute    Add Basic WWW Authentication, the attributes
                    are a colon separated username and password.
    -P attribute    Add Basic Proxy Authentication, the attributes
                    are a colon separated username and password.
    -X proxy:port   Proxyserver and port number to use
    -V              Print version number and exit
    -k              Use HTTP KeepAlive feature
    -d              Do not show percentiles served table.
    -S              Do not show confidence estimators and warnings.
    -q              Do not show progress when doing more than 150 requests
    -l              Accept variable document length (use this for dynamic pages)

    -g filename     Output collected data to gnuplot format file.
    -e filename     Output CSV file with percentages served
    -r              Don"t exit on socket receive errors.
    -m method       Method name
    -h              Display usage information (this message)

英文看不懂,附上中文解釋?zhuān)W(wǎng)上抄的,我沒(méi)試過(guò)

-n 即requests,用于指定壓力測(cè)試總共的執(zhí)行次數(shù)。
-c 即concurrency,用于指定壓力測(cè)試的并發(fā)數(shù)。
-t 即timelimit,等待響應(yīng)的最大時(shí)間(單位:秒)。
-b 即windowsize,TCP發(fā)送/接收的緩沖大小(單位:字節(jié))。
-p 即postfile,發(fā)送POST請(qǐng)求時(shí)需要上傳的文件,此外還必須設(shè)置-T參數(shù)。
-u 即putfile,發(fā)送PUT請(qǐng)求時(shí)需要上傳的文件,此外還必須設(shè)置-T參數(shù)。
-T 即content-type,用于設(shè)置Content-Type請(qǐng)求頭信息,例如:application/x-www-form-urlencoded,默認(rèn)值為text/plain。
-v 即verbosity,指定打印幫助信息的冗余級(jí)別。
-w 以HTML表格形式打印結(jié)果。
-i 使用HEAD請(qǐng)求代替GET請(qǐng)求。
-x 插入字符串作為table標(biāo)簽的屬性。
-y 插入字符串作為tr標(biāo)簽的屬性。
-z 插入字符串作為td標(biāo)簽的屬性。
-C 添加cookie信息,例如:"Apache=1234"(可以重復(fù)該參數(shù)選項(xiàng)以添加多個(gè))。
-H 添加任意的請(qǐng)求頭,例如:"Accept-Encoding: gzip",請(qǐng)求頭將會(huì)添加在現(xiàn)有的多個(gè)請(qǐng)求頭之后(可以重復(fù)該參數(shù)選項(xiàng)以添加多個(gè))。
-A 添加一個(gè)基本的網(wǎng)絡(luò)認(rèn)證信息,用戶名和密碼之間用英文冒號(hào)隔開(kāi)。
-P 添加一個(gè)基本的代理認(rèn)證信息,用戶名和密碼之間用英文冒號(hào)隔開(kāi)。
-X 指定使用的代理服務(wù)器和端口號(hào),例如:"126.10.10.3:88"。
-V 打印版本號(hào)并退出。
-k 使用HTTP的KeepAlive特性。
-k 使用HTTP的KeepAlive特性。
-d 不顯示百分比。
-S 不顯示預(yù)估和警告信息。
-g 輸出結(jié)果信息到gnuplot格式的文件中。
-e 輸出結(jié)果信息到CSV格式的文件中。
-r 指定接收到錯(cuò)誤信息時(shí)不退出程序。
-h 顯示用法信息,其實(shí)就是ab -help。

一般用-n-c,-t就好了
-n請(qǐng)求總數(shù)
-c并發(fā)數(shù)
-t指定秒數(shù)內(nèi)的并發(fā)數(shù)

-t的用法說(shuō)一下,下面的意思是在20秒內(nèi)并發(fā)數(shù)10個(gè)訪問(wèn)

D:phpStudyApachein> ab -c 10 -t 20 http://example.com/phpinfo.php
This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking example.com (be patient)
Finished 3011 requests


Server Software:        nginx/1.6.2
Server Hostname:        example.com
Server Port:            80

Document Path:          /phpinfo.php
Document Length:        94804 bytes

Concurrency Level:      10
Time taken for tests:   20.006 seconds
Complete requests:      3011
Failed requests:        495
   (Connect: 0, Receive: 0, Length: 495, Exceptions: 0)
Non-2xx responses:      54
Total transferred:      280896464 bytes
HTML transferred:       280344222 bytes
Requests per second:    150.50 [#/sec] (mean)
Time per request:       66.444 [ms] (mean)
Time per request:       6.644 [ms] (mean, across all concurrent requests)
Transfer rate:          13711.44 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0      10
Processing:     6   66  17.6     63     203
Waiting:        5   64  17.3     61     202
Total:          6   66  17.6     63     203

Percentage of the requests served within a certain time (ms)
  50%     63
  66%     69
  75%     72
  80%     75
  90%     82
  95%     92
  98%    113
  99%    125
 100%    203 (longest request)

特別說(shuō)明:如果訪問(wèn)http://www.example.com/,沒(méi)有指定特定文件,記得要加最后的那個(gè)/,一定要加?。?!否則可能會(huì)出現(xiàn)訪問(wèn)不到的情況?。?!

可能會(huì)影響基準(zhǔn)測(cè)試的情況

地理位置和網(wǎng)絡(luò)問(wèn)題

響應(yīng)文件大小

代碼的復(fù)雜度

瀏覽器解析

Web服務(wù)器的配置

地理位置和網(wǎng)絡(luò)問(wèn)題

如果Web服務(wù)器存放在境外,那么我們從本地訪問(wèn)境外的網(wǎng)站,可想而知,經(jīng)過(guò)的路由器結(jié)點(diǎn),服務(wù)器結(jié)點(diǎn),再通過(guò)太平洋海底的光纜,而后再訪問(wèn)到Web服務(wù)器,Web服務(wù)器處理后,再繼續(xù)海底光纜,各個(gè)服務(wù)器、路由結(jié)點(diǎn)的跳轉(zhuǎn)返回,這樣的話肯定會(huì)影響到測(cè)試結(jié)果(我的建議是,直接在服務(wù)器上進(jìn)行ab測(cè)試)

響應(yīng)文件大小

假如發(fā)送一個(gè)3MB的頁(yè)面,服務(wù)器網(wǎng)卡會(huì)把3MB的數(shù)據(jù)拆分成單個(gè)很小的數(shù)據(jù)包,傳輸過(guò)程中,只有一個(gè)數(shù)據(jù)包損壞或丟失,則會(huì)重新發(fā)送所有的數(shù)據(jù)包,所以發(fā)送的包越小越好,同時(shí),越小的數(shù)據(jù)傳輸,越快傳輸?shù)接脩舻臋C(jī)器上。

代碼的復(fù)雜度

代碼的復(fù)雜度即是對(duì)業(yè)務(wù)邏輯復(fù)雜的處理,還有對(duì)文件調(diào)用、數(shù)據(jù)庫(kù)訪問(wèn)、遠(yuǎn)端API接口的調(diào)用等等都會(huì)影響處理時(shí)間

瀏覽器解析

每個(gè)瀏覽器都有自己對(duì)js、css、html的處理方法,想想IE8以下和chrome的區(qū)別即可知道

Web服務(wù)器設(shè)置

一般Web服務(wù)器安裝后,簡(jiǎn)單設(shè)置,即可實(shí)現(xiàn)Web服務(wù)(開(kāi)箱即用),但是這樣的設(shè)置沒(méi)有發(fā)揮Web服務(wù)器的最大性能,需要資深的工程師對(duì)服務(wù)器進(jìn)行相關(guān)配置,使之發(fā)揮最大性能,這里簡(jiǎn)單實(shí)用Keep-Alive說(shuō)明。
Keep-Alive的作用就是,Web服務(wù)器打開(kāi)特定數(shù)量的連接,讓這些連接處于打開(kāi)狀態(tài),使之能快速處理傳入的請(qǐng)求,這樣就不會(huì)為每一個(gè)傳入的請(qǐng)求打開(kāi)一個(gè)連接然后處理請(qǐng)求,減少服務(wù)器的處理請(qǐng)求的進(jìn)程數(shù),從而增加并發(fā)數(shù)。
在ab中使用-k進(jìn)行測(cè)試,例如下面這句

#-k,允許服務(wù)器保存5個(gè)并發(fā)連接處于打開(kāi)并允許的狀態(tài),讓其他請(qǐng)求快速處理,減少創(chuàng)建新請(qǐng)求的處理時(shí)間
ab -c 5 -t 100 -k http://www.example.com/

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://www.ezyhdfw.cn/yun/21145.html

相關(guān)文章

  • TensorFlow的多平臺(tái)基準(zhǔn)測(cè)試

    摘要:我們認(rèn)為,在基準(zhǔn)測(cè)試平臺(tái)中,包含真實(shí)數(shù)據(jù)的測(cè)量非常重要。其他結(jié)果訓(xùn)練合成數(shù)據(jù)訓(xùn)練真實(shí)數(shù)據(jù)詳情環(huán)境下表列出了用于測(cè)試的批量大小和優(yōu)化器。在給定平臺(tái)上,以缺省狀態(tài)運(yùn)行。 圖像分類(lèi)模型的結(jié)果InceptionV3[2]、ResNet-50[3]、ResNet-152[4]、VGG16[5] 和 AlexNet[6] 使用 ImageNet[7] 數(shù)據(jù)集進(jìn)行測(cè)試。測(cè)試環(huán)境為 Google Compu...

    jk_v1 評(píng)論0 收藏0
  • 【PHP7源碼分析】PHP7到底有多快,基準(zhǔn)測(cè)試與特性分析告訴你

    摘要:我們修改上面代碼,再來(lái)看下返回值類(lèi)型限制的情況運(yùn)行結(jié)果這段代碼我們額外聲明了返回值的類(lèi)型為型。對(duì)函數(shù)返回值的聲明做了擴(kuò)充,可以定義其返回值為,無(wú)論是否開(kāi)啟嚴(yán)格模式,只要函數(shù)中有以外的其他語(yǔ)句都會(huì)報(bào)錯(cuò)。 順風(fēng)車(chē)運(yùn)營(yíng)研發(fā)團(tuán)隊(duì) 王坤 發(fā)表至21CTO公眾號(hào)(https://mp.weixin.qq.com/s/ph...) showImg(https://segmentfault.c...

    Towers 評(píng)論0 收藏0
  • PHP 性能分析第一篇: Xhprof & Xhgui 介紹

    摘要:注這是我們應(yīng)用性能分析系列的第一篇,閱讀第二篇可深入了解,第三篇?jiǎng)t關(guān)注于性能調(diào)優(yōu)實(shí)踐。性能分析的行為也會(huì)影響應(yīng)用性能。主動(dòng)被動(dòng)性能分析主動(dòng)分析器在開(kāi)發(fā)過(guò)程中使用,由開(kāi)發(fā)人員啟用。它對(duì)性能的影響最小,同時(shí)收集足夠的信息用于診斷性能問(wèn)題。 注:這是我們 PHP 應(yīng)用性能分析系列的第一篇,閱讀第二篇可深入了解 xhgui,第三篇?jiǎng)t關(guān)注于性能調(diào)優(yōu)實(shí)踐。 什么是性能分析? 性能分析是衡量應(yīng)用程...

    RdouTyping 評(píng)論0 收藏0
  • 詳解css相對(duì)定位和絕對(duì)定位

    摘要:以上兩點(diǎn)點(diǎn)可以總結(jié)出,相對(duì)定位總是以父級(jí)左上角為原點(diǎn)進(jìn)行定位的,如果父級(jí)不存在,則以瀏覽器左上角進(jìn)行定位。 贊助我以寫(xiě)出更好的文章,give me a cup of coffee? 2017最新最全前端面試題 案例代碼1 .rel{ border: 1px solid #ccc; height: 200px; ...

    Jaden 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

閱讀需要支付1元查看
<