[core] perf tests
This commit is contained in:
1 parent
78fb4b1a65
commit
a15aacc5b3
4 files changed
+60
-1
No files matched your search
@@ -74,4 +74,5 @@ repos:
|
||||
.pre-commit-config.yaml|
|
||||
^src/core/engines/webjs/session.webjs.core.ts|
|
||||
^src/core/engines/webjs/_lodash.js|
|
||||
^tests/perf/.*|
|
||||
)$
|
||||
+2
-1
@@ -120,7 +120,8 @@
|
||||
"ts-loader": "^6.2.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsconfig-paths": "^4.1.0",
|
||||
"typescript": "^4.8.4"
|
||||
"typescript": "^4.8.4",
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const axios = require('axios');
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const yargs = require('yargs/yargs');
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const { hideBin } = require('yargs/helpers');
|
||||
|
||||
// Parse CLI arguments
|
||||
const argv = yargs(hideBin(process.argv))
|
||||
.option('sessions', {
|
||||
alias: 'n',
|
||||
type: 'number',
|
||||
description: 'Number of sessions to create',
|
||||
default: 10,
|
||||
})
|
||||
.option('api-key', {
|
||||
alias: 'k',
|
||||
type: 'string',
|
||||
description: 'API key for authentication',
|
||||
demandOption: true,
|
||||
})
|
||||
.help().argv;
|
||||
|
||||
const createSessions = async (numSessions, apiKey) => {
|
||||
const url = 'http://localhost:3000/api/sessions/';
|
||||
|
||||
for (let i = 1; i <= numSessions; i++) {
|
||||
try {
|
||||
console.log(`Creating session ${i}`);
|
||||
const response = await axios.post(
|
||||
url,
|
||||
{
|
||||
name: '',
|
||||
config: {
|
||||
metadata: {},
|
||||
webhooks: [],
|
||||
},
|
||||
start: true,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'X-Api-Key': apiKey,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
},
|
||||
);
|
||||
console.log(`Session ${i} created successfully:`, response.data);
|
||||
} catch (error) {
|
||||
console.error(`Error creating session ${i}:`, error.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Run the script
|
||||
createSessions(argv.sessions, argv['api-key']);
|
||||
Reference in new issue
Block a user