Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('performance', () => {
var conns = [];
for (var i = 0; i < 200; i++) {
var conn = new ws.Socket('ws://127.0.0.1:8080/push');
conn.onopen = function () {
this.send(JSON.stringify({
act: "on",
ch: `channel_${cid}`,
timestamp: 0
}));
}
conns.push(conn);
}
coroutine.sleep(1000);
console.time('chat performance');
coroutine.parallel(() => {
for (var i = 0; i < 100; i++) {
it('push', () => {
var conn = new ws.Socket('ws://127.0.0.1:8080/push');
conn.onopen = () => {
conn.send(JSON.stringify({
act: "on",
ch: `channel_${cid}`,
timestamp: 0
}));
}
var r = [];
conn.onmessage = m => {
r.push(m.json());
};
coroutine.sleep(100);
var ws = require('ws');
process.exitCode = 18;
var conn = new ws.Socket("ws://999.99.999.999/not_exists");
conn.onerror = e => {
process.exitCode = 81;
}
it('performance', () => {
var conns = [];
for (var i = 0; i < 200; i++) {
var conn = new ws.Socket(wsBase + '/push');
conn.onopen = function () {
this.send(JSON.stringify({
act: "on",
ch: `channel_${cid}`,
timestamp: 0
}));
}
conns.push(conn);
}
coroutine.sleep(1000);
console.time('chat performance');
coroutine.parallel(() => {
for (var i = 0; i < 100; i++) {
it('push', () => {
var conn = new ws.Socket(wsBase + '/push');
conn.onopen = () => {
conn.send(JSON.stringify({
act: "on",
ch: `channel_${cid}`,
timestamp: 0
}));
}
var r = [];
conn.onmessage = m => {
r.push(m.json());
};
coroutine.sleep(100);