aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/simulate-many-viewers.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-06-17 10:49:37 +0200
committerChocobozzz <me@florianbigard.com>2022-06-17 11:55:03 +0200
commit3396e6534592865f184ee2db32a75957c42cb887 (patch)
tree324aeab92a27f2ffd1e8a16b09f0b5509bf8f477 /scripts/simulate-many-viewers.ts
parentb9e49a45f5441fd1a2d49a10b88aaf4d425dc992 (diff)
downloadPeerTube-3396e6534592865f184ee2db32a75957c42cb887.tar.gz
PeerTube-3396e6534592865f184ee2db32a75957c42cb887.tar.zst
PeerTube-3396e6534592865f184ee2db32a75957c42cb887.zip
Optimize broadcast job creation
Diffstat (limited to 'scripts/simulate-many-viewers.ts')
-rw-r--r--scripts/simulate-many-viewers.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/scripts/simulate-many-viewers.ts b/scripts/simulate-many-viewers.ts
index 4ec928aa8..fb666c318 100644
--- a/scripts/simulate-many-viewers.ts
+++ b/scripts/simulate-many-viewers.ts
@@ -1,6 +1,13 @@
1import Bluebird from 'bluebird' 1import Bluebird from 'bluebird'
2import { wait } from '@shared/core-utils' 2import { wait } from '@shared/core-utils'
3import { createSingleServer, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands' 3import {
4 createSingleServer,
5 doubleFollow,
6 killallServers,
7 PeerTubeServer,
8 setAccessTokensToServers,
9 waitJobs
10} from '@shared/server-commands'
4 11
5let servers: PeerTubeServer[] 12let servers: PeerTubeServer[]
6const viewers: { xForwardedFor: string }[] = [] 13const viewers: { xForwardedFor: string }[] = []
@@ -9,6 +16,7 @@ let videoId: string
9run() 16run()
10 .then(() => process.exit(0)) 17 .then(() => process.exit(0))
11 .catch(err => console.error(err)) 18 .catch(err => console.error(err))
19 .finally(() => killallServers(servers))
12 20
13async function run () { 21async function run () {
14 await prepare() 22 await prepare()
@@ -69,9 +77,13 @@ async function prepare () {
69async function runViewers () { 77async function runViewers () {
70 console.log('Will run views of %d viewers.', viewers.length) 78 console.log('Will run views of %d viewers.', viewers.length)
71 79
80 const before = new Date().getTime()
81
72 await Bluebird.map(viewers, viewer => { 82 await Bluebird.map(viewers, viewer => {
73 return servers[0].views.simulateView({ id: videoId, xForwardedFor: viewer.xForwardedFor }) 83 return servers[0].views.simulateView({ id: videoId, xForwardedFor: viewer.xForwardedFor })
74 }, { concurrency: 100 }) 84 }, { concurrency: 100 })
75 85
86 console.log('Finished to run views in %d seconds.', (new Date().getTime() - before) / 1000)
87
76 await wait(5000) 88 await wait(5000)
77} 89}