forked from zginkgo/runnerGo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
websocket.html
90 lines (77 loc) · 2.46 KB
/
websocket.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>单接口压测</title>
</head>
<body>
<h1>单接口压测</h1><a href="https://github.com/Apipost-Team/runnerGo" target="_blank">https://github.com/Apipost-Team/runnerGo</a>
<pre>
Options:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make at a time
-data <a href="http://www.softwareishard.com/blog/har-12-spec/#request" target="_blank">HAR</a> format data for request
</pre>
<form>
<p> Paras: <textarea id="para" cols="80" rows="36" placeholder="压测参数 c 并发数 n 循环次数 data har 格式的request参数">{
"c": 100,
"n": 2,
"data": {
"method": "GET",
"url": "http://47.96.166.133/index.php",
"mode": "none",
"headers": [
{
"name": "Pragma",
"value": "no-cache"
},
{
"name": "Server",
"value": "yisu.com"
}
],
"postData": {
"params": [
{
"name": "logo",
"type": "file",
"value": "@/Users/mhw/Downloads/"
},
{
"name": "title",
"value": "标题"
}
]
}
}
}</textarea>
<button onclick="send();" id="dobtn" type="button">压测</button>
<textarea id="result" cols="80" rows="36" placeholder="压测结果"></textarea>
</p>
</form>
</body>
<script type="text/javascript">
var sock = null;
var wsuri = "ws://127.0.0.1:10397/websocket";
window.onload = function () {
sock = new WebSocket(wsuri);
sock.onopen = function () {
console.log("connected to " + wsuri);
}
sock.onclose = function (e) {
console.log("connection closed (" + e.code + ")");
}
sock.onmessage = function (e) {
document.getElementById("result").value = JSON.stringify(JSON.parse(e.data), "", "\t")
document.getElementById("dobtn").disabled = ""
document.getElementById("dobtn").innerText = "压测"
}
};
function send() {
document.getElementById("dobtn").disabled = "disabled"
document.getElementById("dobtn").innerText = "压测中"
var msg = document.getElementById('para').value;
sock.send(msg);
};
</script>
</html>