hiper
1.0.0
英語| 中文
績效測試的統計分析工具
這個名稱為hi hi formance hi或hi gh gh gh
大家好,請用英語介紹您的問題
請使用英語提問題
npm install hiper -g
# or use yarn:
# yarn global add hiper 注意: It takes period (m)s to load ... 。 period意味著此測試需要時間。所以-n上升,時期上升。不是錯誤
| 鑰匙 | 價值 |
|---|---|
| DNS查找時間 | domainlookupend -domainlookupstart |
| TCP連接時間 | Connectend -ConnectStart |
| TTFB | 響應 - 請求start |
| 下載頁面的時間 | 響應設備 - 響應 |
| DOM準備下載時間後 | DOMCOMPLETE -DOMITHACTIVE |
| 白屏幕時間 | DomInteractive -NavigationStart |
| DOM準備時間 | domcontentloadedEventend -avarigationStart |
| 加載時間 | loadeventend -avarigationStart |
https://developer.mozilla.org/en-us/docs/web/api/performancetiming
hiper --help
Usage: hiper [options] [url]
A statistical analysis tool for performance testing
Options:
-v, --version output the version number
-n, --count < n > specified loading times (default: 20)
-c, --config < path > load the configuration file
-u, --useragent < ua > to set the useragent
-H, --headless [b] whether to use headless mode (default: true)
-e, --executablePath < path > use the specified chrome browser
--no-cache disable cache (default: false)
--no-javascript disable javascript (default: false)
--no-online disable network (defalut: false)
-h, --help output usage information例如
# We can omit the protocol header if has omitted, the protocol header will be `https://`
# The simplest usage
hiper baidu.com
# if the url has any parameter, surround the url with double quotes
hiper " baidu.com?a=1&b=2 "
# Load the specified page 100 times
hiper -n 100 " baidu.com?a=1&b=2 "
# Load the specified page 100 times without `cache`
hiper -n 100 " baidu.com?a=1&b=2 " --no-cache
# Load the specified page 100 times without `javascript`
hiper -n 100 " baidu.com?a=1&b=2 " --no-javascript
# Load the specified page 100 times with `headless = false`
hiper -n 100 " baidu.com?a=1&b=2 " -H false
# Load the specified page 100 times with set `useragent`
hiper -n 100 " baidu.com?a=1&b=2 " -u " Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36 " .json和.js配置 {
// options Pointing to a specific chrome executable, this configuration is generally not required unless you want to test a specific version of chrome
"executablePath" : "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ,
// required The url you want to test
"url" : "https://example.com" ,
// options Cookies required for this test. It's usually a cookie for login information Array | Object
"cookies" : [ {
"name" : "token" ,
"value" : "9+cL224Xh6VuRT" ,
"domain" : "example.com" ,
"path" : "/" ,
"size" : 294 ,
"httpOnly" : true
} ] ,
// options default: 20 Test times
"count" : 100 ,
// options default: true Whether to use headless mode
"headless" : true ,
// options default: false Disable cache
"noCache" : false ,
// options default: false Disable javascript
"noJavascript" : false ,
// options default: false Disable network
"noOnline" : false ,
// options Set the useragent information
"useragent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36" ,
// options Set the viewport information
"viewport" : {
// options
"width" : 375 ,
// options
"height" : 812 ,
// options default: 1 devicePixelRatio
"deviceScaleFactor" : 3 ,
// options default: false Whether to simulate mobile
"isMobile" : false ,
// options default: false Whether touch events are supported
"hasTouch" : false ,
// options default: false Is it horizontal or not
"isLandscape" : false
}
}擁有用於配置的JS文件允許人們使用ENV變量。例如,假設我想以身份驗證的狀態測試該站點。我可以傳遞一些用來通過ENV變量識別我的cookie,並且擁有基於JS的配置文件使它變得簡單。例如
module . exports = {
... .
cookies : [ {
name : 'token' ,
value : process . env . authtoken ,
domain : 'example.com' ,
path : '/' ,
httpOnly : true
} ] ,
... .
} # Load the above configuration file (Let's say this file is under /home/)
hiper -c /home/config.json
# Or you can also use JS files for configuration
hiper -c /home/config.js在我們開發項目或優化項目的性能之後,
我們如何衡量該項目的性能?
一種常見的方法是查看Dev Tool中的performance和network中的數據,記錄一些關鍵性能指標,並在查看這些性能指標之前刷新幾次,
有時,我們發現由於樣本量較小,當前網絡/CPU/內存負載受到嚴重影響,有時優化的項目比優化之前慢。
如果有一個工具,請多次請求網頁,然後取出各種績效指標,我們可以非常準確地知道優化是正面的或負面的。
此外,您還可以進行比較並獲取有關優化量的準確數據。該工具旨在解決疼痛點。
同時,此工具也是我們了解“瀏覽器的負載和渲染過程”和“性能優化”的好工具,因此當樣本太少時,我們不會得出錯誤的結論
麻省理工學院
歡迎明星和公關
版權(C)2018 Liyanfeng(POD4G)