|
@@ -5,17 +5,20 @@ const url = process.argv[2];
|
|
const count = process.argv[3];
|
|
const count = process.argv[3];
|
|
const userStartId = process.argv[4];
|
|
const userStartId = process.argv[4];
|
|
const testSceneNum = process.argv[5] || "t-test";
|
|
const testSceneNum = process.argv[5] || "t-test";
|
|
-const roomId = process.argv[6] || "00001";
|
|
|
|
|
|
+const roomStartId = process.argv[6] || "00001";
|
|
const isMockCamera = process.argv[7] || 0;
|
|
const isMockCamera = process.argv[7] || 0;
|
|
const cameraInterval = process.argv[8] || 3000;
|
|
const cameraInterval = process.argv[8] || 3000;
|
|
|
|
+const roomNumber = process.argv[9] || 50;
|
|
let testCamera;
|
|
let testCamera;
|
|
console.log(
|
|
console.log(
|
|
"argv:",
|
|
"argv:",
|
|
|
|
+ count,
|
|
userStartId,
|
|
userStartId,
|
|
testSceneNum,
|
|
testSceneNum,
|
|
- roomId,
|
|
|
|
|
|
+ roomStartId,
|
|
isMockCamera,
|
|
isMockCamera,
|
|
- cameraInterval
|
|
|
|
|
|
+ cameraInterval,
|
|
|
|
+ roomNumber
|
|
);
|
|
);
|
|
|
|
|
|
console.log("socket-info::url:config-->", url);
|
|
console.log("socket-info::url:config-->", url);
|
|
@@ -24,9 +27,11 @@ console.log("socket-info::start-->压力测试正在开始");
|
|
const URL = url || process.env.URL;
|
|
const URL = url || process.env.URL;
|
|
// http://zhang9394@zhangyupeng:face3d.4dage.com:7005/zhangyupeng/chatIM.git
|
|
// http://zhang9394@zhangyupeng:face3d.4dage.com:7005/zhangyupeng/chatIM.git
|
|
const MAX_CLIENTS = Number(count) || 500;
|
|
const MAX_CLIENTS = Number(count) || 500;
|
|
-const CLIENT_CREATION_INTERVAL_IN_MS = 10;
|
|
|
|
-const EMIT_INTERVAL_IN_MS = 1000;
|
|
|
|
-const EMIT_INTERVAL_IN_MS_camera = cameraInterval;
|
|
|
|
|
|
+
|
|
|
|
+// const CLIENT_CREATION_INTERVAL_IN_MS = 0;
|
|
|
|
+// // const EMIT_INTERVAL_IN_MS = 100;
|
|
|
|
+// const EMIT_INTERVAL_IN_MS_camera = Number(cameraInterval);
|
|
|
|
+// let sendcameraIntervalTimer;
|
|
// wws://test-socket.4dkankan.com/watch
|
|
// wws://test-socket.4dkankan.com/watch
|
|
let clientCount = 0;
|
|
let clientCount = 0;
|
|
let lastReport = new Date().getTime();
|
|
let lastReport = new Date().getTime();
|
|
@@ -35,6 +40,31 @@ let packetsSinceLastReport = 0;
|
|
// let roomId = "00001";
|
|
// let roomId = "00001";
|
|
let userLimitNum = MAX_CLIENTS;
|
|
let userLimitNum = MAX_CLIENTS;
|
|
let agentId = 0;
|
|
let agentId = 0;
|
|
|
|
+function sleep(ms) {
|
|
|
|
+ return new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
|
+}
|
|
|
|
+function range(start, end) {
|
|
|
|
+ return Array(end - start + 1)
|
|
|
|
+ .fill()
|
|
|
|
+ .map((_, idx) => start + idx);
|
|
|
|
+}
|
|
|
|
+const groups = (arr, chunkSize) => {
|
|
|
|
+ return arr
|
|
|
|
+ .map((e, i) => {
|
|
|
|
+ return i % chunkSize === 0 ? arr.slice(i, i + chunkSize) : null;
|
|
|
|
+ })
|
|
|
|
+ .filter((e) => {
|
|
|
|
+ return e;
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// new Array(Number(count)).fill(0).forEach((_, index) => {
|
|
|
|
+// // console.log("agent", index);
|
|
|
|
+// const isLast = (index + 1) % roomNumber === 0;
|
|
|
|
+// if (isLast) {
|
|
|
|
+// console.log("isLast", index);
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
|
|
const createAgent = () => {
|
|
const createAgent = () => {
|
|
agentId += 1;
|
|
agentId += 1;
|
|
@@ -42,12 +72,16 @@ const createAgent = () => {
|
|
const userId = `${userStartId}${agentId}`;
|
|
const userId = `${userStartId}${agentId}`;
|
|
const oid = `oid-${userStartId}${agentId}`;
|
|
const oid = `oid-${userStartId}${agentId}`;
|
|
const role = agentId === 1 ? "leader" : "customer";
|
|
const role = agentId === 1 ? "leader" : "customer";
|
|
- createClient({ userId, nickName, from: "0", role: role, oid });
|
|
|
|
- createClient({ userId, nickName, from: "1", role: role, oid });
|
|
|
|
- createClient({ userId, nickName, from: "2", role: role, oid });
|
|
|
|
|
|
+ const roomId = "";
|
|
|
|
+
|
|
|
|
+ console.log("agentId", agentId);
|
|
|
|
+
|
|
|
|
+ // createClient({ userId, nickName, from: "0", role: role, oid });
|
|
|
|
+ // createClient({ userId, nickName, from: "1", role: role, oid });
|
|
|
|
+ // createClient({ userId, nickName, from: "2", role: role, oid });
|
|
};
|
|
};
|
|
|
|
|
|
-const createClient = ({ userId, nickName, from, role, oid }) => {
|
|
|
|
|
|
+const createClient = ({ userId, nickName, from, role, oid, roomId }) => {
|
|
// for demonstration purposes, some clients stay stuck in HTTP long-polling
|
|
// for demonstration purposes, some clients stay stuck in HTTP long-polling
|
|
|
|
|
|
const socket = io(URL, {
|
|
const socket = io(URL, {
|
|
@@ -74,52 +108,53 @@ const createClient = ({ userId, nickName, from, role, oid }) => {
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
|
|
- if (Number(isMockCamera) === 1) {
|
|
|
|
- setInterval(() => {
|
|
|
|
- const data = {
|
|
|
|
- testUserId: userId,
|
|
|
|
- item: {
|
|
|
|
- qua: {
|
|
|
|
- _x: -0.11495106988815072,
|
|
|
|
- _y: 0.13408027376477993,
|
|
|
|
- _z: 0.015660797097947755,
|
|
|
|
- _w: 0.9841562229407423,
|
|
|
|
- },
|
|
|
|
- mode: "panorama",
|
|
|
|
- pos: {
|
|
|
|
- x: 1.7477431297302246,
|
|
|
|
- y: -0.1338435709476471,
|
|
|
|
- z: 1.3797638416290283,
|
|
|
|
- },
|
|
|
|
- type: "Rotate",
|
|
|
|
- pano: "1",
|
|
|
|
- target: {
|
|
|
|
- x: 1.4874317088952322,
|
|
|
|
- y: -0.3643028004004215,
|
|
|
|
- z: 0.442146378191566,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- };
|
|
|
|
- socket.emit("client-benmark-server", data);
|
|
|
|
- }, EMIT_INTERVAL_IN_MS_camera);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- setInterval(() => {
|
|
|
|
- socket.emit("client to server event");
|
|
|
|
- }, EMIT_INTERVAL_IN_MS);
|
|
|
|
-
|
|
|
|
- socket.on("server-benmark-client", (data) => {
|
|
|
|
- packetsSinceLastReport++;
|
|
|
|
- testCamera = data;
|
|
|
|
- // console.log("客户端收到服务端-镜头-MOCK", data);
|
|
|
|
- });
|
|
|
|
|
|
+ // if (Number(isMockCamera) === 1 && Number(from) === 0) {
|
|
|
|
+ // console.log(userId + "底层v3开启发送镜头");
|
|
|
|
+ // setInterval(() => {
|
|
|
|
+ // const data = {
|
|
|
|
+ // testUserId: userId,
|
|
|
|
+ // item: {
|
|
|
|
+ // qua: {
|
|
|
|
+ // _x: -0.11495106988815072,
|
|
|
|
+ // _y: 0.13408027376477993,
|
|
|
|
+ // _z: 0.015660797097947755,
|
|
|
|
+ // _w: 0.9841562229407423,
|
|
|
|
+ // },
|
|
|
|
+ // mode: "panorama",
|
|
|
|
+ // pos: {
|
|
|
|
+ // x: 1.7477431297302246,
|
|
|
|
+ // y: -0.1338435709476471,
|
|
|
|
+ // z: 1.3797638416290283,
|
|
|
|
+ // },
|
|
|
|
+ // type: "Rotate",
|
|
|
|
+ // pano: "1",
|
|
|
|
+ // target: {
|
|
|
|
+ // x: 1.4874317088952322,
|
|
|
|
+ // y: -0.3643028004004215,
|
|
|
|
+ // z: 0.442146378191566,
|
|
|
|
+ // },
|
|
|
|
+ // },
|
|
|
|
+ // };
|
|
|
|
+ // socket.emit("client to server event", data);
|
|
|
|
+ // }, EMIT_INTERVAL_IN_MS_camera);
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // setInterval(() => {
|
|
|
|
+ // socket.emit("client to server event");
|
|
|
|
+ // }, EMIT_INTERVAL_IN_MS);
|
|
|
|
+
|
|
|
|
+ // socket.on("server-benmark-client", (data) => {
|
|
|
|
+ // packetsSinceLastReport++;
|
|
|
|
+ // testCamera = data;
|
|
|
|
+ // // console.log("客户端收到服务端-镜头-MOCK", data);
|
|
|
|
+ // });
|
|
|
|
|
|
// socket.emit("server-interval-room-broadcast", { time: 1000 });
|
|
// socket.emit("server-interval-room-broadcast", { time: 1000 });
|
|
// socket.on("client-interval-room-broadcast", (data) => {
|
|
// socket.on("client-interval-room-broadcast", (data) => {
|
|
// console.log(`客户端${userId}收到房间播报-MOCK"`, data);
|
|
// console.log(`客户端${userId}收到房间播报-MOCK"`, data);
|
|
// });
|
|
// });
|
|
|
|
|
|
- socket.on("server to client event", () => {
|
|
|
|
|
|
+ socket.on("server to client event", (data) => {
|
|
packetsSinceLastReport++;
|
|
packetsSinceLastReport++;
|
|
});
|
|
});
|
|
|
|
|
|
@@ -127,12 +162,42 @@ const createClient = ({ userId, nickName, from, role, oid }) => {
|
|
console.log(`disconnect due to ${reason}`);
|
|
console.log(`disconnect due to ${reason}`);
|
|
});
|
|
});
|
|
|
|
|
|
- if (++clientCount < MAX_CLIENTS) {
|
|
|
|
- setTimeout(createAgent, CLIENT_CREATION_INTERVAL_IN_MS);
|
|
|
|
- }
|
|
|
|
|
|
+ // if (++clientCount < MAX_CLIENTS) {
|
|
|
|
+ // setTimeout(createAgent, CLIENT_CREATION_INTERVAL_IN_MS);
|
|
|
|
+ // }
|
|
};
|
|
};
|
|
|
|
|
|
-createAgent();
|
|
|
|
|
|
+const chunkSize = Number(roomNumber);
|
|
|
|
+const arr = range(1, Number(count));
|
|
|
|
+
|
|
|
|
+groups(arr, chunkSize).forEach((group, gIndex) => {
|
|
|
|
+ // console.log("group", group);
|
|
|
|
+
|
|
|
|
+ Array.from(group).forEach(async (agent, index) => {
|
|
|
|
+ try {
|
|
|
|
+ // console.log("agent-1", agent, gIndex + 1);
|
|
|
|
+ const nickName = `test_name_${userStartId}${agent}`;
|
|
|
|
+ const userId = `${userStartId}${agent}`;
|
|
|
|
+ const oid = `oid-${userStartId}${agent}`;
|
|
|
|
+ const roomId = `${roomStartId}${gIndex + 1}`;
|
|
|
|
+ let role = index === 0 ? "leader" : "customer";
|
|
|
|
+ console.log("agent-2", {
|
|
|
|
+ userId,
|
|
|
|
+ nickName,
|
|
|
|
+ role,
|
|
|
|
+ oid,
|
|
|
|
+ roomId,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ createClient({ userId, nickName, from: "0", role: role, oid, roomId });
|
|
|
|
+ createClient({ userId, nickName, from: "1", role: role, oid, roomId });
|
|
|
|
+ createClient({ userId, nickName, from: "2", role: role, oid, roomId });
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.log("初始化");
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+});
|
|
|
|
+// createAgent();
|
|
|
|
|
|
const printReport = () => {
|
|
const printReport = () => {
|
|
const now = new Date().getTime();
|
|
const now = new Date().getTime();
|
|
@@ -151,4 +216,4 @@ const printReport = () => {
|
|
lastReport = now;
|
|
lastReport = now;
|
|
};
|
|
};
|
|
|
|
|
|
-setInterval(printReport, 5000);
|
|
|
|
|
|
+// setInterval(printReport, 5000);
|