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)