MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / runScenario

Method runScenario

benchmark/src/benchmark.ts:63–89  ·  view source on GitHub ↗
(
    name: string,
    scenarioFactory: ScenarioFactory,
  )

Source from the content-addressed store, hash-verified

61 }
62
63 async runScenario(
64 name: string,
65 scenarioFactory: ScenarioFactory,
66 ): Promise<EndpointStats> {
67 debug('Starting scenario %j', name);
68 const {worker, url} = await startWorker();
69 debug('Worker started - pid=%s url=%s', worker.pid, url);
70
71 const client = new Client(url);
72 const autocannon = this.cannonFactory(url);
73
74 const runner = new scenarioFactory();
75 debug('Setting up the scenario');
76 await runner.setup(client);
77 debug('Pinging the app');
78 await client.ping();
79 debug('Starting the stress test.');
80 const result = await runner.execute(autocannon);
81 debug('Stats: %j', result);
82
83 await closeWorker(worker);
84 debug('Worker stopped, done.');
85
86 this.logger(name, result);
87
88 return result;
89 }
90}
91
92function startWorker() {

Callers 1

runMethod · 0.95

Calls 6

pingMethod · 0.95
startWorkerFunction · 0.85
closeWorkerFunction · 0.85
setupMethod · 0.65
executeMethod · 0.65
loggerMethod · 0.45

Tested by

no test coverage detected