Skip to content

Commit

Permalink
modify benchmark host
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce authored and Bruce committed Sep 3, 2021
1 parent 02fb9ba commit 49af63d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
./**/config/pro.json
yarn*.log
node_modules
doc
doc
logs
13 changes: 7 additions & 6 deletions packages/wsrpc/tests/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import Ws from 'ws'
import { randomId } from '@elara/lib'
const log = console

const port = 9944
const host = '127.0.0.1'
const port = 9000

async function sleeps(s: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, s * 1000))
Expand Down Expand Up @@ -89,7 +90,7 @@ enum WsTyp {
}

export const wsTestRunner = async (loop: number, newConn: boolean, conn: number, type: WsTyp) => {
let wss = connBuild(conn, '127.0.0.1', port)
let wss = connBuild(conn, host, port)
let lis = topics
if (type === WsTyp.Rpc) {
lis = methods
Expand All @@ -99,13 +100,13 @@ export const wsTestRunner = async (loop: number, newConn: boolean, conn: number,
if (loop <= 0) { loop = Number.MAX_VALUE }
for (let i = 0; i < loop; i++) {
if (wss.length === 0) {
wss = connBuild(conn, '127.0.0.1', port)
wss = connBuild(conn, host, port)
}

for (let w of wss) {
listenHandle(w, lis, loop, newConn)
}
await sleeps(10)
await sleeps(6)
if (newConn) {
clearConn(wss)
wss = []
Expand All @@ -124,7 +125,7 @@ const connTestRunner = async (conn: number, delay: number) => {
let wss = []
let pat = 'polkadot/'
for (let i = 0; i < conn; i++) {
const ws = newConn('127.0.0.1', port, `${pat}00000000000000000000000000000000`)
const ws = newConn(host, port, `${pat}00000000000000000000000000000000`)
ws.on('open', () => {
log.info('open ws id: %o', i)
})
Expand Down Expand Up @@ -153,7 +154,7 @@ const connTest = async (loop: number) => {

(async () => {
if (true) {
wsTestRunner(0, true, 100, WsTyp.All)
wsTestRunner(0, true, 500, WsTyp.All)

} else {
// wsTestRunner(0, false, 100)
Expand Down

0 comments on commit 49af63d

Please sign in to comment.