Skip to content

Commit

Permalink
feat: added perf test and output to JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Jul 26, 2023
1 parent e21cda8 commit b1d89bd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/perf/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class DefaultPerfService implements Startable, PerfService {
}

log('performed %s to %p', this.protocol, peer)
stream.close()
await stream.close()
}

// measureDownloadBandwidth returns the measured bandwidth in bits per second
Expand Down
68 changes: 34 additions & 34 deletions packages/perf/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,41 @@ export const defaultInit: PerfServiceInit = {

const argv = yargs
.options({
'run-server': {
type: 'boolean',
demandOption: true,
default: false,
description: 'Whether to run as a server',
},
'server-ip-address': {
type: 'string',
demandOption: false,
description: 'Server IP address',
default: '',
},
'transport': {
type: 'string',
demandOption: false,
description: 'Transport to use',
default: 'tcp'
},
'upload-bytes': {
type: 'number',
demandOption: false,
description: 'Number of bytes to upload',
default: 0
},
'download-bytes': {
type: 'number',
demandOption: false,
description: 'Number of bytes to download',
default: 0
},
'run-server': {
type: 'boolean',
demandOption: true,
default: false,
description: 'Whether to run as a server',
},
'server-ip-address': {
type: 'string',
demandOption: false,
description: 'Server IP address',
default: '',
},
'transport': {
type: 'string',
demandOption: false,
description: 'Transport to use',
default: 'tcp'
},
'upload-bytes': {
type: 'number',
demandOption: false,
description: 'Number of bytes to upload',
default: 0
},
'download-bytes': {
type: 'number',
demandOption: false,
description: 'Number of bytes to download',
default: 0
},
})
.command('help', 'Print usage information', yargs.help)
.parseSync()

export async function main(runServer: boolean, serverIpAddress: string, transport: string, uploadBytes: number, downloadBytes: number): void {
export async function main(runServer: boolean, serverIpAddress: string, transport: string, uploadBytes: number, downloadBytes: number): Promise<void> {
const listenAddrs: Multiaddr[] = []

if (runServer === true) {
Expand All @@ -72,10 +72,10 @@ export async function main(runServer: boolean, serverIpAddress: string, transpor
const remoteComponents = await createComponents()

const client = perfService(defaultInit)(localComponents)
const server = perfService(defaultInit)(remoteComponents)
const server = perfService(defaultInit)(remoteComponents)

await start(client)
await start(server)
await start(client)
await start(server)

const startTime = Date.now()

Expand Down
2 changes: 1 addition & 1 deletion packages/perf/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { start, stop } from '@libp2p/interface/startable'
import { connectionPair } from '@libp2p/interface-compliance-tests/mocks'
import { expect } from 'aegir/chai'
import { type Components } from 'libp2p/components'
import type { Components } from 'libp2p/components'
import { perfService } from '../src/index.js'
import { createComponents, defaultInit } from '../src/main.js'

Expand Down

0 comments on commit b1d89bd

Please sign in to comment.