/* eslint-disable no-console */ import { INestApplication } from '@nestjs/common'; import { GlobalFlag } from '@vendure/common/lib/generated-types'; import { bootstrap, Importer, isGraphQlErrorResult, LanguageCode, OrderService, RequestContextService, } from '@vendure/core'; import { populate } from '@vendure/core/cli/populate'; import { ParsedProductWithVariants } from '@vendure/core/src/index'; import { clearAllTables } from '@vendure/testing'; import { spawn } from 'child_process'; import program from 'commander'; import path from 'path'; import ProgressBar from 'progress'; import { getLoadTestConfig } from './load-test-config'; /** * This set of benchmarks aims to specifically test the performance issues discussed * in issue https://github.com/vendurehq/vendure/issues/1506. * * In order to test these issues, we need a test dataset that will create: * * 1. 1k Products, each with 10 ProductVariants * 2. 10k Orders, each with 10 OrderLines, each OrderLine with qty 5 * * Then we will test: * * 1. Fetching 10 Products from the `products` query. This will test the effects of indexes, ListQueryBuilder & dataloader * 2. As above but with Orders * 3. Fetching a list of orders and selecting only the Order id. * This will test optimization of selecting & joining only the needed fields. */ const DATABASE_NAME = 'vendure-benchmarks'; const PRODUCT_COUNT = 1000; const VARIANTS_PER_PRODUCT = 10; const ORDER_COUNT = 10000; const LINES_PER_ORDER = 10; const QUANTITY_PER_ORDER_LINE = 5; interface Options { script?: string; db: 'mysql' | 'postgres'; populate?: boolean; variant?: string; } program .option('--script