MCPcopy Create free account
hub / github.com/msgbyte/tailchat / handler

Function handler

apps/cli/src/commands/benchmark/register.ts:42–83  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

40 type: 'boolean',
41 }),
42 async handler(args) {
43 const url = args.url as string;
44 const file = args.file as string;
45 const count = args.count as number;
46 const concurrency = args.concurrency as number;
47 const invite = args.invite as string | undefined;
48 const append = (args.append ?? false) as boolean;
49 const tokens: string[] = [];
50 const start = Date.now();
51
52 const spinner = ora().info(`Register temporary account`).start();
53
54 let i = 0;
55 spinner.text = `Progress: ${i}/${count}`;
56 await pMap(
57 Array.from({ length: count }),
58 async () => {
59 const token = await registerTemporaryAccount(url, `benchUser-${i}`);
60 if (invite) {
61 // Apply group invite
62 await applyGroupInviteCode(url, token, invite);
63 }
64 if (append) {
65 await fs.appendFile(file, `\n${token}`);
66 }
67
68 spinner.text = `Progress: ${++i}/${count}`;
69 tokens.push(token);
70 },
71 {
72 concurrency,
73 }
74 );
75
76 if (!append) {
77 spinner.info(`Writing tokens into path: ${file}`);
78
79 await fs.writeFile(file, tokens.join('\n'));
80 }
81
82 spinner.succeed(`Register completed! Usage: ${Date.now() - start}ms`);
83 },
84};
85
86async function registerTemporaryAccount(

Callers

nothing calls this directly

Calls 5

registerTemporaryAccountFunction · 0.85
applyGroupInviteCodeFunction · 0.85
startMethod · 0.80
infoMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected