Skip to content

Commit

Permalink
simpler duration and parellelism
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed May 8, 2024
1 parent d77aa70 commit c60a4e6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 0 additions & 2 deletions e2e/sqlite-chinook/sqlite-chinook.loadtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ it(`should perform within threshold ${JSON.stringify(threshold)}`, async () => {

const { maxCpu, maxMem, slowestRequest } = await tbench.serveSustain({
serve: await serve({ fusiongraph: output }),
duration: 10_000,
parallelRequestsPerVU: 10,
params: {
query: /* GraphQL */ `
query Albums {
Expand Down
23 changes: 17 additions & 6 deletions e2e/utils/tbench.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setTimeout } from 'timers/promises';
import { spawn, Thread, Worker } from 'threads';
import { Serve } from './tenv';
import { timeout as jestTimeout, Serve } from './tenv';
import type { benchGraphQLServer } from './workers/benchGraphQLServer';

const leftovers = new Set<Thread>();
Expand All @@ -15,10 +15,16 @@ afterAll(async () => {
export interface ServeSustainOptions {
/** The serve process to benchmark. */
serve: Serve;
/** How long should the benchmark run for. */
duration: number;
/** How many parallel requests should each VU perform. */
parallelRequestsPerVU: number;
/**
* How long should the benchmark run for.
* @default jest.timeout - 1second
*/
duration?: number;
/**
* How many parallel requests should each VU perform.
* @default 10
*/
parallelRequestsPerVU?: number;
/** GraphQL parameters to use. */
params: {
query: string;
Expand Down Expand Up @@ -54,7 +60,12 @@ export async function createTbench(vus: number): Promise<Tbench> {
);
workers.forEach(worker => leftovers.add(worker));
return {
async serveSustain({ serve, duration, parallelRequestsPerVU, params }) {
async serveSustain({
serve,
duration = jestTimeout - 1_000,
parallelRequestsPerVU = 10,
params,
}) {
let maxCpu = 0;
let maxMem = 0;
const signal = AbortSignal.timeout(duration);
Expand Down
2 changes: 1 addition & 1 deletion e2e/utils/tenv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Dockerode from 'dockerode';
import { ExecutionResult } from 'graphql';
import { createArg, createPortArg, createServicePortArg } from './args';

const retries = 120,
export const retries = 120,
interval = 500,
timeout = retries * interval; // 1min
jest.setTimeout(timeout);
Expand Down

0 comments on commit c60a4e6

Please sign in to comment.