|
@@ -6,8 +6,17 @@ const count = process.argv[3];
|
|
|
const userStartId = process.argv[4];
|
|
|
const testSceneNum = process.argv[5] || "t-test";
|
|
|
const roomId = process.argv[6] || "00001";
|
|
|
-
|
|
|
-console.log("argv", userStartId, testSceneNum, roomId);
|
|
|
+const isMockCamera = process.argv[7] || 0;
|
|
|
+const cameraInterval = process.argv[8] || 3000;
|
|
|
+let testCamera;
|
|
|
+console.log(
|
|
|
+ "argv:",
|
|
|
+ userStartId,
|
|
|
+ testSceneNum,
|
|
|
+ roomId,
|
|
|
+ isMockCamera,
|
|
|
+ cameraInterval
|
|
|
+);
|
|
|
|
|
|
console.log("socket-info::url:config-->", url);
|
|
|
console.log("socket-info::url:count-->", count);
|
|
@@ -15,9 +24,9 @@ console.log("socket-info::start-->压力测试正在开始");
|
|
|
const URL = url || process.env.URL;
|
|
|
// http://zhang9394@zhangyupeng:face3d.4dage.com:7005/zhangyupeng/chatIM.git
|
|
|
const MAX_CLIENTS = Number(count) || 500;
|
|
|
-const POLLING_PERCENTAGE = 0.05;
|
|
|
const CLIENT_CREATION_INTERVAL_IN_MS = 10;
|
|
|
const EMIT_INTERVAL_IN_MS = 1000;
|
|
|
+const EMIT_INTERVAL_IN_MS_camera = cameraInterval;
|
|
|
// wws://test-socket.4dkankan.com/watch
|
|
|
let clientCount = 0;
|
|
|
let lastReport = new Date().getTime();
|
|
@@ -31,19 +40,23 @@ const createAgent = () => {
|
|
|
agentId += 1;
|
|
|
const nickName = `test_name_${userStartId}${agentId}`;
|
|
|
const userId = `${userStartId}${agentId}`;
|
|
|
+ const oid = `oid-${userStartId}${agentId}`;
|
|
|
const role = agentId === 1 ? "leader" : "customer";
|
|
|
- createClient({ userId, nickName, from: "0", role: role });
|
|
|
- createClient({ userId, nickName, from: "1", role: role });
|
|
|
- createClient({ userId, nickName, from: "2", role: role });
|
|
|
+ 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 }) => {
|
|
|
+const createClient = ({ userId, nickName, from, role, oid }) => {
|
|
|
// for demonstration purposes, some clients stay stuck in HTTP long-polling
|
|
|
|
|
|
const socket = io(URL, {
|
|
|
path: "/fsl-node",
|
|
|
- transport: ["websocket"],
|
|
|
+ transports: ["websocket"],
|
|
|
parser: customParser,
|
|
|
+ extraHeaders: {
|
|
|
+ oid: oid,
|
|
|
+ },
|
|
|
query: {
|
|
|
userId: userId,
|
|
|
from: from || 2,
|
|
@@ -61,10 +74,51 @@ const createClient = ({ userId, nickName, from, role }) => {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
+ 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);
|
|
|
+ });
|
|
|
+
|
|
|
+ // socket.emit("server-interval-room-broadcast", { time: 1000 });
|
|
|
+ // socket.on("client-interval-room-broadcast", (data) => {
|
|
|
+ // console.log(`客户端${userId}收到房间播报-MOCK"`, data);
|
|
|
+ // });
|
|
|
+
|
|
|
socket.on("server to client event", () => {
|
|
|
packetsSinceLastReport++;
|
|
|
});
|
|
@@ -88,7 +142,9 @@ const printReport = () => {
|
|
|
).toFixed(2);
|
|
|
|
|
|
console.log(
|
|
|
- `client count: ${clientCount} ; average packets received per second: ${packetsPerSeconds}`
|
|
|
+ `client count: ${clientCount} ; average packets received per second: ${packetsPerSeconds} ${
|
|
|
+ testCamera ? " carmera:" + JSON.stringify(testCamera) : ""
|
|
|
+ }`
|
|
|
);
|
|
|
|
|
|
packetsSinceLastReport = 0;
|