Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
haoban3.0
haoban-manage3.0
Commits
b3e11c5c
Commit
b3e11c5c
authored
Oct 29, 2024
by
王祖波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
8a6510ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
QWmediaTest.java
haoban-manage3-service/src/test/java/QWmediaTest.java
+10
-6
No files found.
haoban-manage3-service/src/test/java/QWmediaTest.java
View file @
b3e11c5c
...
...
@@ -55,8 +55,9 @@ public class QWmediaTest {
}
public
static
void
main
(
String
[]
args
)
{
int
TOTAL_REQUESTS
=
100
;
// 总请求数
int
TOTAL_REQUESTS
=
1
8
00
;
// 总请求数
List
<
String
>
list
=
FileUtil
.
readLines
(
"/Users/wang/Downloads/image.txt"
,
"UTF-8"
);
List
<
String
>
qrList
=
FileUtil
.
readLines
(
"/Users/wang/Downloads/qrcode.txt"
,
"UTF-8"
);
JSONObject
jo
=
new
JSONObject
();
jo
.
put
(
"wxEnterpriseId"
,
"b18ffdc9d0644912865a248859914d80"
);
jo
.
put
(
"qrCodeUrl"
,
"https://gicinner-1251519181.cos.ap-shanghai.myqcloud.com/image/material_content-4ffc77073ca1476fb264bf1be9f11383.png"
);
...
...
@@ -65,8 +66,8 @@ public class QWmediaTest {
jo
.
put
(
"lineTwo"
,
"宇智222为您推荐"
);
jo
.
put
(
"mediaType"
,
1
);
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
5
0
);
// 创建线程池
Semaphore
semaphore
=
new
Semaphore
(
50
);
// 限制并发请求数为5
0
ExecutorService
executorService
=
Executors
.
newFixedThreadPool
(
3
0
);
// 创建线程池
Semaphore
semaphore
=
new
Semaphore
(
30
);
// 限制并发请求数为3
0
// 用于统计请求耗时
AtomicLong
totalTime
=
new
AtomicLong
(
0
);
...
...
@@ -74,13 +75,15 @@ public class QWmediaTest {
AtomicLong
minTime
=
new
AtomicLong
(
Long
.
MAX_VALUE
);
for
(
int
i
=
0
;
i
<
TOTAL_REQUESTS
;
i
++)
{
final
int
requestId
=
i
;
final
int
imageId
=
i
%
9
;
final
int
qrId
=
i
/
9
;
executorService
.
submit
(()
->
{
long
startTime
=
System
.
currentTimeMillis
();
try
{
semaphore
.
acquire
();
// 获取许可,控制并发请求
jo
.
put
(
"imageUrl"
,
list
.
get
(
requestId
));
HttpResponse
execute
=
HttpRequest
.
post
(
"https://www.gicdev.com/haoban-manage3-wx/combined-qw-materialid.json"
).
timeout
(
1000000
).
body
(
jo
.
toJSONString
()).
execute
();
jo
.
put
(
"imageUrl"
,
list
.
get
(
imageId
));
jo
.
put
(
"qrCodeUrl"
,
qrList
.
get
(
qrId
));
HttpResponse
execute
=
HttpRequest
.
post
(
"https://www.gicdev.com/haoban-manage3-wx/combined-qw-materialid.json"
).
timeout
(-
1
).
body
(
jo
.
toJSONString
()).
execute
();
String
body
=
execute
.
body
();
String
headerValue
=
execute
.
header
(
"x-request-id"
);
// String post = HttpUtil.post("https://www.gicdev.com/haoban-manage3-wx/combined-qw-materialid.json", jo.toJSONString());
...
...
@@ -90,6 +93,7 @@ public class QWmediaTest {
System
.
out
.
println
(
"异常: "
+
e
.
getMessage
());
}
finally
{
long
duration
=
System
.
currentTimeMillis
()
-
startTime
;
System
.
out
.
println
(
duration
);
totalTime
.
addAndGet
(
duration
);
maxTime
.
updateAndGet
(
x
->
Math
.
max
(
x
,
duration
));
minTime
.
updateAndGet
(
x
->
Math
.
min
(
x
,
duration
));
...
...
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