Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
benchmark
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
benchmark
Commits
83186670
Commit
83186670
authored
Feb 23, 2024
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update test script
parent
bcfc6589
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
181 additions
and
1 deletion
+181
-1
async-request.js
http/async-request.js
+115
-0
async.js
http/async.js
+65
-0
http.js
http/http.js
+1
-1
No files found.
http/async-request.js
0 → 100644
View file @
83186670
import
http
from
'
k6/http
'
;
import
{
check
}
from
"
k6
"
;
export
const
options
=
{
// A number specifying the number of VUs to run concurrently.
vus
:
10
,
// A string specifying the total duration of the test run.
duration
:
'
30s
'
};
export
default
async
()
=>
{
let
array
=
new
Array
(
1000
);
for
(
let
i
=
0
;
i
<
array
.
length
;
i
++
)
{
//array[i] = i + 1; // 从1开始赋值
array
[
i
]
=
http
.
asyncRequest
(
'
POST
'
,
'
http://192.168.1.220:8000/api/v1/demianhjw/aigic/0129
'
,
{
"
model_name
"
:
"
Realistic_Vision_V1.4
"
,
"
model_type
"
:
"
tex2img
"
,
"
desc
"
:
{
"
prompt
"
:
"
a small car
"
,
"
steps
"
:
20
}
},
{
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
"
apikey
"
:
"
6r9aCCENYah5KPARJ4GLFmlOLs0uAEr2
"
,
"
async
"
:
"
true
"
}
});
}
//console.log(array); // 输出: [1, 2, 3, 4, 5]
const
res
=
await
Promise
.
all
(
array
)
check
(
res
,
{
"
status is 200
"
:
(
r
)
=>
r
.
status
===
200
,
// "is key correct": (r) => j.json.key === "value",
});
// console.log('----', res);
}
/*
curl --location --request POST 'http://192.168.1.220:8000/api/v1/txt2Img/demianhjw/aigic' \
--header 'apikey: 6r9aCCENYah5KPARJ4GLFmlOLs0uAEr2' \
--header 'Content-Type: application/json' \
--header 'async":true' \
--data-raw '{
"model_name": "Realistic_Vision_V1.4",
"model_type": "tex2img",
"desc": {
"prompt": "small noodles",
"steps": 20
}
}'
curl http://192.168.1.220:8000/api/v1/demianhjw/aigic/0129 -H "Content-Type: application/json" -H "apikey: 6r9aCCENYah5KPARJ4GLFmlOLs0uAEr2" -H "async:true" -d '{
"model_name": "Realistic_Vision_V1.4",
"model_type": "tex2img",
"desc": {
"prompt": " a small car",
"steps": 20
}
}'
*/
// export default async () => {
// const urlOne = `https://httpbin.test.k6.io/delay/${randomInt(1, 5)}`
// const urlTwo = `https://httpbin.test.k6.io/delay/${randomInt(1, 5)}`
// const urlThree = `https://httpbin.test.k6.io/delay/${randomInt(1, 5)}`
// const urlFour = `https://httpbin.test.k6.io/delay/${randomInt(1, 5)}`
// const urlFive = `https://httpbin.test.k6.io/delay/${randomInt(1, 5)}`
// const one = http.asyncRequest('GET', urlOne);
// const two = http.asyncRequest('GET', urlTwo);
// const three = http.asyncRequest('GET', urlThree);
// const four = http.asyncRequest('GET', urlFour);
// const five = http.asyncRequest('GET', urlFive);
// console.log('Racing:')
// console.log(urlOne);
// console.log(urlTwo);
// console.log(urlThree);
// console.log(urlFour);
// console.log(urlFive);
// const res = await Promise.race([one, two, three,four,five])
// console.log('winner is', res.url, 'with duration of', res.timings.duration+'ms');
// }
// function randomInt(min, max) {
// return Math.floor(Math.random() * (max - min) + min);
// }
\ No newline at end of file
http/async.js
0 → 100644
View file @
83186670
import
{
Httpx
}
from
'
https://jslib.k6.io/httpx/0.1.0/index.js
'
;
import
{
check
}
from
"
k6
"
;
const
session
=
new
Httpx
({
//http://192.168.1.220:8000/api/v1/demianhjw/aigic/0129
//baseURL: 'http://192.168.1.220:8000/api/v1/demianhjw/aigic/0129',
baseURL
:
'
http://192.168.1.220:8000
'
,
//baseURL: 'https://httpbin.test.k6.io',
timeout
:
20000
,
// 20s timeout.
});
export
default
function
testSuite
()
{
// let body = JSON.stringify({
// "model_name": "Realistic_Vision_V1.4",
// "model_type": "tex2img",
// "desc": {
// "prompt": " a small car",
// "steps": 20
// }
// });
//asyncRequest(method, url, [body], [params])
//var currentTime = new Date();
// console.log("await beginTime",currentTime);
//const respPost = await session.asyncPost(`/api/v1/demianhjw/aigic/0129`, {
const
respPost
=
session
.
asyncPost
(
`/api/v1/demianhjw/aigic/0129`
,
{
"
model_name
"
:
"
Realistic_Vision_V1.4
"
,
"
model_type
"
:
"
tex2img
"
,
"
desc
"
:
{
"
prompt
"
:
"
a small car
"
,
"
steps
"
:
20
}
},
{
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
"
apikey
"
:
"
6r9aCCENYah5KPARJ4GLFmlOLs0uAEr2
"
,
"
async
"
:
"
true
"
}
});
//var endTime = new Date();
//console.log("endTime",endTime);
//console.log(respPost.body)
// check(respPost, {
// "status is 200": (r) => r.status === 200,
// // "is key correct": (r) => j.json.key === "value",
// });
// const resp_get = await session.asyncRequest('GET', `/status/200`);
// const resp_post = await session.asyncRequest('POST', `/status/200`, { key: 'value' });
// const resp_put = await session.asyncRequest('PUT', `/status/200`, { key: 'value' });
// const resp_patch = await session.asyncRequest('PATCH', `/status/200`, { key: 'value' });
// const resp_delete = await session.asyncRequest('DELETE', `/status/200`);
// // specific methods are also available.
// const respGet = await session.asyncGet(`/status/200`);
// const respPost = await session.asyncPost(`/status/200`, { key: 'value' });
// const respPut = await session.asyncPut(`/status/200`, { key: 'value' });
// const respPatch = await session.asyncPatch(`/status/200`, { key: 'value' });
// const respDelete = await session.asyncDelete(`/status/200`);
}
\ No newline at end of file
http/http.js
View file @
83186670
...
@@ -86,7 +86,7 @@ export default function() {
...
@@ -86,7 +86,7 @@ export default function() {
let
res
=
http
.
post
(
'
http://192.168.1.220:8000/api/v1/demianhjw/aigic/0129
'
,
body
,
{
headers
:
let
res
=
http
.
post
(
'
http://192.168.1.220:8000/api/v1/demianhjw/aigic/0129
'
,
body
,
{
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
{
"
Content-Type
"
:
"
application/json
"
,
"
apikey
"
:
"
6r9aCCENYah5KPARJ4GLFmlOLs0uAEr2
"
,
"
apikey
"
:
"
6r9aCCENYah5KPARJ4GLFmlOLs0uAEr2
"
,
"
sync
"
:
"
true
"
}
"
a
sync
"
:
"
true
"
}
});
});
// Use JSON.parse to deserialize the JSON (instead of using the r.json() method)
// Use JSON.parse to deserialize the JSON (instead of using the r.json() method)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment