-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(network): 加入一次性载入大量图片的网页,用以HTTP 1.1测试队头阻塞以及chrome浏览器请求数限制
Chrome浏览器单个用户配置文件,同源、正在处理的网络请求(或者说TCP连接?未测试当有WebSocket存在时的情况)只能同时存在6个(标签页之间共享这个配额),超过6个将发生阻塞(资源请求我页中,浏览器将左下角提示“正在等待可用的套接字”)
- Loading branch information
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
network/performance-test/tons-of-images-loading-process.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>一次性载入大量图片(通过src资源请求)</title> | ||
<script src="/vue2/vue.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div id="app"> | ||
<img v-for="url in targetUrlList" title="url" :src="url" /> | ||
</div> | ||
|
||
<script> | ||
let app = new Vue({ | ||
el: '#app', | ||
methods: { | ||
}, | ||
data () { | ||
return { | ||
targetImageUrl: '/_res/color-linear-gradient.png', | ||
targetUrlList: [] | ||
} | ||
}, | ||
mounted () { | ||
let targetUrlList = [] | ||
let exceptImageCount = 1000 | ||
|
||
const baseUrlList = [ | ||
'//localhost:8500', | ||
'//127.0.0.1:8500', | ||
] | ||
|
||
for (let i=0; i<exceptImageCount;i++ ) { | ||
targetUrlList.push(`${baseUrlList[i%baseUrlList.length]}${this.targetImageUrl}?index=${i}`) | ||
} | ||
// debugger | ||
this.targetUrlList = targetUrlList | ||
} | ||
}) | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>一次性载入大量图片(通过xhr)</title> | ||
<script src="/vue2/vue.js"></script> | ||
<script src="/_lib/axios.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div id="app"> | ||
<img v-for="url in targetUrlList" title="url" :src="url" /> | ||
</div> | ||
|
||
<script> | ||
let app = new Vue({ | ||
el: '#app', | ||
methods: { | ||
}, | ||
data () { | ||
return { | ||
targetImageUrl: '/_res/color-linear-gradient.png', | ||
targetUrlList: [] | ||
} | ||
}, | ||
mounted () { | ||
let targetUrlList = [] | ||
let exceptImageCount = 1000 | ||
|
||
const baseUrlList = [ | ||
'//localhost:8500', | ||
'//127.0.0.1:8500', | ||
] | ||
|
||
for (let i=0; i<exceptImageCount;i++ ) { | ||
const baseURL = baseUrlList[i%baseUrlList.length] | ||
axios.get(`${baseUrlList[i%baseUrlList.length]}${this.targetImageUrl}?index=${i}`, { | ||
responseType: 'blob', | ||
// timeout: | ||
}).then(({data}) => { | ||
targetUrlList.push(URL.createObjectURL(data)) | ||
}).catch((err) => { | ||
console.log(err) | ||
}) | ||
} | ||
// debugger | ||
this.targetUrlList = targetUrlList | ||
} | ||
}) | ||
</script> | ||
</body> | ||
|
||
</html> |